-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
74 lines (72 loc) · 1.83 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
'use strict';
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = require('./config.json');
module.exports = {
'entry': 'main',
'output': {
'path': 'dist/js',
'publicPath': './js/',
'filename': 'wallblog.js'
},
module: {
loaders: [
{
test: /sw\/.*\.js$/,
loader: 'webpack-append',
query: `const vapidPublicKey = '${config.vapidPublicKey}';`
},
{
test: /main.js$/,
loader: 'webpack-append',
query: `const blogTitle = '${config.blogTitle}';`
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.hbs$/,
loader: 'handlebars-loader?helperDirs[]=' + __dirname + '/app/js/helpers'
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
'plugins': [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /(fr|en)/),
new CopyWebpackPlugin([
{
from: 'app/js/sw/service-worker.js',
to: `../service-worker.js`,
transform: function(content) {
let fileContent = content.toString();
fileContent = fileContent.replace(/WEBSITE_URL/, config.websiteUrl);
fileContent = fileContent.replace(/NOTIFICATION_TITLE/, config.notificationTitle);
fileContent = fileContent.replace(/CURRENT_VERSION/, `v${Date.now()}`);
return fileContent;
}
}
])
],
'resolve': {
'root': [
__dirname + '/app/js',
],
'extensions': ['', '.js', '.hbs', '.json'],
'alias': {
'templates': __dirname + '/app/templates'
}
}
};