-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
84 lines (76 loc) · 1.94 KB
/
webpack.config.babel.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
import path from 'path';
import merge from 'webpack-merge';
import StaticSiteGeneratorPlugin from 'static-site-generator-webpack-plugin';
import HtmlPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
const dist = path.join(__dirname, 'dist');
const cssLoaders = ExtractTextPlugin.extract({
fallback: 'style-loader',
use: {
loader: 'css-loader',
query: {
modules: true,
sourceMap: true,
},
},
});
const cssPlugin = new ExtractTextPlugin({
filename: '[name].css',
});
const common = {
output: {
path: dist,
filename: '[name].js',
chunkFilename: '[id].js',
},
module: {
rules: [{
test: /\.css$/,
loader: cssLoaders,
}, {
test: /\.pug$/,
use: "pug-loader"
}]
},
plugins: [
cssPlugin,
]
};
const variation = {};
switch (process.env.VAR) {
case 'fst' :
variation.entry = {
'pages': './config/fst/pages.js',
'main': './src/pages/main.js',
'second/second': './src/pages/second/second.js',
};
variation.output = {
libraryTarget: 'umd',
};
variation.plugins = [
new StaticSiteGeneratorPlugin({
entry: 'pages'
}),
];
break;
case 'sec' :
variation.entry = {
'main': './config/sec/main.js',
'second/second': './config/sec/second/second.js',
};
variation.output = {
libraryTarget: 'umd',
};
variation.plugins = [
new HtmlPlugin({
chunks: ['main'],
filename: 'main.html',
}),
new HtmlPlugin({
chunks: ['second'],
filename: 'second/second.html',
}),
];
break;
}
export default merge(common, variation);