forked from kamilio/axiom-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.static.config.js
85 lines (84 loc) · 2.09 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: [
'babel-polyfill',
'./site/static.js',
],
module: {
rules: [{
test: /\.js$/,
use: ['babel-loader'],
include: [
/packages/,
/site/,
/style-guide/,
/node_modules\/get-own-enumerable-property-symbols/,
/node_modules\/stringify-object/,
],
}, {
test: /\.ejs$/,
use: ['ejs-loader'],
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract({
use: [{
loader: 'css-loader',
options: {
importLoaders: 1,
minimize: true,
},
}, {
loader: 'postcss-loader',
}],
}),
}],
},
output: {
filename: './assets/bundle.[hash].min.js',
path: path.resolve(__dirname, 'public'),
publicPath: '/',
libraryTarget: 'umd',
},
plugins: [
new CleanWebpackPlugin(['public']),
new ExtractTextPlugin({
filename: './assets/bundle.[hash].min.css',
}),
new CopyWebpackPlugin([{
from: './site/assets',
to: './assets',
}]),
new StaticSiteGeneratorPlugin({
crawl: true,
paths: ['/', '/docs/packages'],
}),
new webpack.EnvironmentPlugin({ NODE_ENV: 'production' }),
new UglifyJSPlugin({
uglifyOptions: {
ecma: 6,
mangle: {
keep_classnames: true,
keep_fnames: true,
},
},
}),
...(process.env.COMPRESSION_PLUGIN ? [new CompressionPlugin({
asset: '[path]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
})] : []),
],
resolveLoader: {
modules: [
'node_modules',
'packages',
],
},
};