-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathwebpack.config.js
90 lines (82 loc) · 2.16 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
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var nodeModulesPath = path.join(__dirname, 'node_modules');
var isProduction = process.env.NODE_ENV == "production";
var config = {
entry: {
vendors: [
'react',
'react-dom',
'redux',
'react-redux',
'redux-thunk',
'redux-logger',
'babel-polyfill',
path.join(__dirname, 'babel', 'babelhelpers.js')
],
app: [
path.join(__dirname, 'App', 'Index.tsx')
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.less', '.css'],
modules: ["node_modules", "resources"],
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name]_[chunkhash].js'
},
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'tslint-loader',
options: { emitErrors: true }
},
{
test: /\.tsx?$/,
loaders: ["babel-loader?cacheDirectory", "awesome-typescript-loader?tsconfig=tsconfig.webpack.json&useCache=true"]
},
{
test: /\.css$/,
loaders: ["style-loader", "css-loader?minimize"]
},
{
test: /\.less$/,
exclude: /\.module\.less$/,
loaders: ["style-loader", "css-loader?minimize", "less-loader?compress"]
},
{
test: /\.module\.less$/,
loaders: ["style-loader", "css-loader?minimize&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]", "less-loader?-compress"]
},
{
test: /\.(jpg|png|woff|eot|ttf|svg|gif)$/,
loader: "file-loader?name=[name]_[hash].[ext]"
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendors_[hash].js' }),
new HtmlWebpackPlugin({
template: 'index.html'
}),
new webpack.DefinePlugin({
DEBUG: true
})
]
};
if (isProduction) {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
config.plugins.push(new webpack.DefinePlugin({
'process.env': {NODE_ENV: '"production"'},
DEBUG: false
}));
}
module.exports = config;