-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
112 lines (104 loc) · 2.73 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const nodeModulesPath = path.join(__dirname, 'node_modules');
const isProduction = process.env.NODE_ENV == 'production';
const config = {
entry: {
vendors: [
'react',
'react-dom',
'redux',
'react-redux',
'redux-thunk',
'redux-logger',
'babel-polyfill',
path.join(__dirname, 'babel', 'helpers.js')
],
app: [
path.join(__dirname, 'App', 'Index.tsx')
]
},
resolve: {
extensions: [
'.tsx',
'.ts',
'.js',
'.less',
'.css'
],
modules: [
"node_modules",
"resources"
]
},
output: {
path: path.join(__dirname, 'public'),
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&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;