-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathwebpack.config.js
56 lines (46 loc) · 1.09 KB
/
webpack.config.js
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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path')
const merge = require('webpack-merge');
const webpack = require('webpack');
const TARGET = process.env.NODE_ENV;
const PRODUCTION = TARGET === 'production';
const DEVELOPMENT = TARGET === 'development' || !TARGET;
let config = {
entry: './src/index.tsx',
output: {
path: path.resolve('./build'),
publicPath: '/static/',
filename: 'bundle.js',
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js']
},
module: {
loaders: [
{ test: /\.tsx?$/, loader: 'ts-loader' },
],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/assets/index.html',
favicon: 'src/assets/favicon.png',
inject: true,
}),
],
devtool: '#cheap-module-inline-source-map',
devServer: {
contentBase: './build',
historyApiFallback: {
index: '/static/',
},
port: 4999,
noInfo: true,
},
};
if (PRODUCTION) {
config = merge(config, {
devtool: '#source-map',
});
}
module.exports = config;