-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathwebpack.config.js
82 lines (74 loc) · 1.93 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
const
path = require('path'),
SWPrecacheWebpackPlugin = require('../lib/index'),
HtmlWebpackPlugin = require('html-webpack-plugin');
// sw-precache-webpack-plugin configurations
const SERVICE_WORKER_FILENAME = 'my-service-worker.js';
const SERVICE_WORKER_CACHEID = 'my-project-name';
const SERVICE_WORKER_IGNORE_PATTERNS = [/dist\/.*\.html/];
const SW_PRECACHE_CONFIG = {
minify: true,
cacheId: SERVICE_WORKER_CACHEID,
filename: SERVICE_WORKER_FILENAME,
// staticFileGlobsIgnorePatterns: SERVICE_WORKER_IGNORE_PATTERNS,
};
const HTML_WEBPACK_OPTIONS = {
main: {
title: 'examples',
template: 'src/templates/default.ejs',
inject: false,
appMountId: 'main',
serviceWorker: `/${SERVICE_WORKER_FILENAME}`,
},
};
module.exports = {
context: __dirname,
entry: {
main: path.resolve(__dirname, 'src/index'),
},
output: {
path: path.resolve(__dirname, 'dist/'),
filename: '[name]-[hash].js',
publicPath: 'http://localhost:3000/',
},
plugins: [
new HtmlWebpackPlugin(HTML_WEBPACK_OPTIONS.main),
new SWPrecacheWebpackPlugin(SW_PRECACHE_CONFIG),
], // add all common plugins here
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
}],
},
{
test: /\.ejs$/,
use: [{
loader: 'ejs-loader',
options: {
includePaths: [
path.resolve(__dirname, 'src/templates/'),
],
},
}],
},
{test: /\.(png|jpg|gif)$/, use: [{
loader: 'url-loader',
options: {limit: 8192},
}]}, // inline base64 URLs <=8k
{test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: [{
loader: 'file-loader',
}]},
], // add all common loaders here
},
resolve: {
extensions: ['.js', '.jsx'],
modules: [
path.resolve(__dirname, 'src'),
'node_modules',
],
},
};