-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathwebpack.resources.config.js
62 lines (61 loc) · 1.64 KB
/
webpack.resources.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
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const packageJSON = require('./package.json');
const version = packageJSON.version;
module.exports = {
entry: ['./src/index.js'],
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel'],
}, {
test: /\.s?css$/,
loader: ExtractTextPlugin.extract('style', 'css?minimize!postcss!sass'),
}],
},
output: {
filename: './dist/axiom.min.js',
},
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new CleanWebpackPlugin(['dist']),
new ExtractTextPlugin('./dist/axiom.min.css', { allChunks: true }),
new ExtractTextPlugin(`./dist/axiom.${version}.min.css`, { allChunks: true }),
new webpack.DefinePlugin({
__INCLUDE_CSS__: true,
__DEVELOPMENT__: false,
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
mangle: {
keep_fnames: true,
},
}),
new CompressionPlugin({
asset: '[path]',
algorithm: 'gzip',
test: /\.js$|\.css$/,
threshold: 10240,
minRatio: 0.8,
}),
],
resolve: {
alias: {
'bw-axiom': path.resolve(__dirname, 'src'),
},
},
postcss: () => [
autoprefixer({ browsers: ['last 2 versions'] }),
],
};