-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (61 loc) · 1.58 KB
/
webpack.config.js
File metadata and controls
68 lines (61 loc) · 1.58 KB
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
var webpack = require('webpack');
var path = require('path');
var AppCachePlugin = require('appcache-webpack-plugin');
var fs = require('fs');
var plugins = [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
},
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(false),
new AppCachePlugin({
output: 'main.appcache',
cache: fs.readdirSync('public/fonts')
.filter(f => f[0] != '.')
.map(f => 'fonts/' + f)
.concat(['main.css'])
})
];
if (process.env.NODE_ENV != 'development')
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true,
unsafe: true,
collapse_vars: true,
passes: 2
}
}));
module.exports = {
context: path.join(__dirname, 'app'),
entry: './index',
output: {
path: path.join(__dirname, 'public'),
filename: 'app.js'
},
plugins: plugins,
module: {
loaders: [{
test: /\.css$/,
loader: 'style!css?modules&camelcase&localIdentName=[sha1:hash:base64:4]!postcss'
}, {
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel?loose=all'
}]
},
postcss: function () {
var autoprefixer = require('autoprefixer'),
precss = require('precss'),
inlinesvg = require('postcss-inline-svg'),
cssnano = require('cssnano');
return [
precss(),
inlinesvg(),
autoprefixer({ browsers: ['last 1 version'] }),
cssnano()
];
}
};