forked from krzysztofsaja/angular-weather-widget
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.ts
67 lines (65 loc) · 1.7 KB
/
webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as webpack from 'webpack';
import * as path from 'path';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
const IS_PROD: boolean = process.argv.indexOf('-p') > -1;
const OPEN_WEATHER_MAP_API_KEY = process.env.OPEN_WEATHER_MAP_API_KEY;
export default {
devtool: IS_PROD ? 'source-map' : 'eval',
entry: path.join(__dirname, 'demo', 'entry.ts'),
output: {
filename: IS_PROD ? '[name]-[chunkhash].js' : '[name].js'
},
module: {
rules: [{
test: /\.ts$/,
loader: 'prettier-loader',
exclude: /node_modules/,
enforce: 'pre',
options: {
singleQuote: true,
parser: 'typescript'
}
}, {
test: /\.ts$/,
loader: 'tslint-loader',
exclude: /node_modules/,
enforce: 'pre'
}, {
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
transpileOnly: !IS_PROD
}
}]
},
resolve: {
extensions: ['.ts', '.js']
},
devServer: {
port: 3001,
inline: true,
hot: true,
historyApiFallback: true
},
plugins: [
...(IS_PROD ? [] : [
new webpack.HotModuleReplacementPlugin(),
new ForkTsCheckerWebpackPlugin({
watch: ['./src', './demo']
})
]),
new webpack.DefinePlugin({
ENV: JSON.stringify(IS_PROD ? 'production' : 'development'),
OPEN_WEATHER_MAP_API_KEY: JSON.stringify(OPEN_WEATHER_MAP_API_KEY)
}),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
path.join(__dirname, 'src')
),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'demo', 'index.ejs')
})
]
};