-
Notifications
You must be signed in to change notification settings - Fork 119
/
webpack.config.js
96 lines (80 loc) · 2.07 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'use strict';
const path = require("path");
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const baseAppEntries = [
'./src/index.tsx',
];
const devAppEntries = [
'webpack-hot-middleware/client?reload=true',
];
const appEntries = baseAppEntries
.concat(process.env.NODE_ENV === 'development' ? devAppEntries : []);
const basePlugins = [
new webpack.DefinePlugin({
__DEV__: process.env.NODE_ENV !== 'production'
}),
new webpack.optimize.CommonsChunkPlugin('vendor', '[name].[hash].js'),
new HtmlWebpackPlugin({
template: './src/index.html',
inject: 'body'
})
];
const devPlugins = [
new webpack.HotModuleReplacementPlugin(),
];
const prodPlugins = [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
];
const plugins = basePlugins
.concat(process.env.NODE_ENV === 'production' ? prodPlugins : [])
.concat(process.env.NODE_ENV === 'development' ? devPlugins : []);
module.exports = {
entry: {
app: appEntries,
vendor: [
'react',
'react-dom',
'react-redux',
'redux',
'redux-thunk',
'redux-logger'
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[hash].js',
publicPath: "/",
sourceMapFilename: '[name].[hash].js.map',
chunkFilename: '[id].chunk.js'
},
devtool: 'source-map',
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.tsx', '.js']
},
plugins: plugins,
module: {
preLoaders: [{
test: /\.tsx?$/,
loader: 'tslint'
}],
loaders: [
{ test: /\.tsx?$/, loader: 'ts-loader', exclude: /node_modules/ },
{ test: /\.html$/, loader: 'raw' },
{ test: /\.css$/, loader: 'style-loader!css-loader?sourceMap' },
{ test: /\.svg/, loader: 'url' },
{ test: /\.eot/, loader: 'url' },
{ test: /\.woff/, loader: 'url' },
{ test: /\.woff2/, loader: 'url' },
{ test: /\.ttf/, loader: 'url' },
]
},
ts: {
// https://github.com/Microsoft/TypeScript/issues/5478
ignoreDiagnostics: [2605, 2345]
}
}