-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
77 lines (74 loc) · 2 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
var production = process.env.NODE_ENV == 'prod';
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var extractCss = new ExtractTextPlugin('dist.css');
module.exports = {
devtool: production ? false : 'eval',
entry: './src/main.jsx',
output: {
path: __dirname + '/dist',
filename: 'dist.js'
},
resolve: {
extensions: ['', '.js', '.jsx', '.less', '.css', '.json'],
modulesDirectories: ['node_modules'],
alias: {
'src': path.join(__dirname, 'src'),
'lib': path.join(__dirname, 'lib'),
'res': path.join(__dirname, 'res')
}
},
module: {
loaders: [
{
test: /\.jsx$/,
loader: 'babel-loader',
query: {
presets: [ 'es2015' ],
plugins: [ 'mjsx' ]
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.less$/,
loader: extractCss.extract('style-loader', 'css-loader?minimize!less-loader')
},
{
test: /\.css$/,
loader: extractCss.extract('style-loader', 'css-loader?minimize')
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'base64-prefix-loader?dataPrefix',
'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
cache: false,
template: production ? 'res/html/index.ejs' : 'res/html/index.html',
filename: __dirname + '/dist/torque-helper.html',
minify: {
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
}
}),
production && new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false }
}),
extractCss
].filter(x => x)
};