-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
114 lines (111 loc) · 2.63 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const path = require('path')
const site = require('./src/_data/site.js')
const webpack = require('webpack')
// Plugins
const { WebpackManifestPlugin } = require('webpack-manifest-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const WorkboxPlugin = require('workbox-webpack-plugin')
// The output filename
const filename = '[name]' + (site.environment === 'production' ? '.[contenthash]' : '')
module.exports = {
entry: {
main: {
import: [
path.resolve(__dirname, 'src/js', 'index.js'),
path.resolve(__dirname, 'src/css', 'main.css')
]
},
homepage: {
filename: filename + '.js',
import: path.resolve(__dirname, 'src/js', 'homepage.js')
},
homepage_worker: {
filename: filename + '.js',
import: path.resolve(__dirname, 'src/js/homepage', 'worker.js')
},
tools: {
filename: filename + '.js',
import: path.resolve(__dirname, 'src/js', 'tools.js')
}
},
resolve: {
alias: {
'~': path.resolve(__dirname, 'node_modules/')
}
},
output: {
path: path.resolve(__dirname, 'docs', 'assets'),
filename: filename + '.js',
publicPath: '/assets/',
clean: {
keep: /images|videos/
},
library: {
name: 'tools',
type: 'assign-properties'
}
},
module: {
rules: [
{
test: /\.css$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: true
}
},
'postcss-loader'
],
exclude: /node_modules/
},
{
test: /\.woff(2)?(\?[a-z0-9]+)?$/,
use: [{
loader: 'url-loader',
options: {
name: 'fonts/[name].[ext]'
}
}]
},
{
test: /\.(jpg|jpeg|gif|png)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
}
}]
},
{
test: /\.(ttf|eot|svg)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
}]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: filename + '.css'
}),
new WebpackManifestPlugin({
fileName: 'manifest.json',
publicPath: '/assets/'
}),
new webpack.DefinePlugin({
APP_SERVICE_URL: JSON.stringify(process.env.APP_SERVICE_URL)
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
swDest: '../service-worker.js'
})
]
}