-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
68 lines (67 loc) · 2.24 KB
/
webpack.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
var webpack = require('webpack');
var path = require('path');
var BabiliPlugin = require('babili-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
var WorkboxBuildWebpackPlugin = require('workbox-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
'sw': path.join(__dirname, 'src/components/serviceworker/sw.js'),
'main': path.join(__dirname, 'src/index.js')
},
output: {
path: path.join(__dirname, 'docs'),
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
plugins: [require('babel-plugin-transform-object-rest-spread')]
}
}
},
{test: /\.scss$/, use: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])},
{
test: /\.twig$/,
use: [
'babel-loader',
{
loader: 'melody-loader',
options: {
plugins: ['idom']
}
}
]
},
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new BabiliPlugin({}, {comments: false}),
new ExtractTextPlugin('main.css'),
new CopyWebpackPlugin([
{ from: require.resolve('workbox-sw'), to: 'workbox-sw.js' }
]),
new WorkboxBuildWebpackPlugin({
globDirectory: './docs',
globPatterns: ['**/*.{html,js,css,svg,md,png,json,ico}'],
globIgnores: ['sw.js','workbox-sw.js'],
swSrc: path.join(__dirname, 'src', 'components', 'serviceworker', 'sw.js'),
swDest: path.join(__dirname, 'docs', 'sw.js'),
})
],
devServer: {
contentBase: path.join(__dirname, 'docs'),
watchOptions: {
ignored: /node_modules/,
},
overlay: false,
}
};