-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathwebpack.static.config.js
70 lines (69 loc) · 2.01 KB
/
webpack.static.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
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 CopyWebpackPlugin = require('copy-webpack-plugin');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
const structureGenerator = require('./scripts/structure-generator');
module.exports = {
entry: {
main: './style-guide/static.js',
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel'],
}, {
test: /\.json$/,
loaders: ['json'],
}, {
test: /\.ejs$/,
loaders: ['ejs'],
}, {
test: /\.s?css$/,
loader: ExtractTextPlugin.extract('style', 'css?minimize!postcss!sass'),
}],
},
output: {
filename: './assets/bundle.min.js',
path: './static/',
publicPath: '/',
libraryTarget: 'umd',
},
plugins: [
new CleanWebpackPlugin(['static']),
new ExtractTextPlugin('./assets/bundle.min.css', { allChunks: true }),
new CopyWebpackPlugin([{ from: './style-guide/assets', to: './assets' }]),
new StaticSiteGeneratorPlugin('main', structureGenerator.extractPaths()),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
mangle: {
keep_fnames: true,
},
}),
new webpack.DefinePlugin({
__INCLUDE_CSS__: true,
__STRUCTURE__: JSON.stringify(structureGenerator()),
__BASENAME__: process.env.BASENAME_ENV || '"/"',
__DEVELOPMENT__: false,
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
],
resolve: {
alias: {
'bw-axiom': path.resolve(__dirname, 'src'),
'style-guide': path.resolve(__dirname, 'style-guide/components'),
},
},
postcss: () => [
autoprefixer({ browsers: ['last 2 versions'] }),
],
};