This repository was archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.production.js
More file actions
executable file
·117 lines (116 loc) · 3.08 KB
/
webpack.production.js
File metadata and controls
executable file
·117 lines (116 loc) · 3.08 KB
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
115
116
117
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest');
const OfflinePlugin = require('offline-plugin');
module.exports = {
devtool: 'source-map',
entry: {
bundle: './src/app.jsx',
editor: './src/editor.js',
},
output: {
path: path.join(__dirname, 'wp-content/themes/wp-react-theme/build'),
filename: '[name].[hash].js',
// TODO use CDN like so: 'https://xxx.cloudfront.net/wp-content/themes/wp-react-theme/build/'
publicPath: '/wp-content/themes/wp-react-theme/build/'
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
loaders: [
{
enforce: 'pre',
test: /\.jsx?$/,
// Skip any files outside of your project's `src` directory
include: [
path.resolve(__dirname, 'src'),
],
loader: 'eslint-loader',
},
{
test: /\.jsx?$/,
// Skip any files outside of your project's `src` directory
include: [
path.resolve(__dirname, 'src'),
],
loader: 'babel-loader',
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
},
{
loader: 'sass-loader',
},
],
}),
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=fonts/[name].[ext]',
},
],
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(), // Webpack will let you know if there are any errors
new ExtractTextPlugin('[name].[hash].css'),
new StyleLintPlugin({
configFile: '.stylelintrc',
context: 'src',
files: '**/*.scss',
}),
// TODO Uncomment and adjust to your needs
// new WebpackPwaManifest({
// fingerprints: false,
// name: 'name',
// short_name: 'short_name',
// description: 'description',
// background_color: '#f9f6f6',
// theme_color: '#5a3a3b',
// icons: [
// {
// src: path.resolve('src/icon.png'),
// sizes: [16, 48, 72, 96, 144, 168, 192, 512],
// },
// ],
// }),
new OfflinePlugin({
externals: [
'/',
'https://cdnjs.cloudflare.com/ajax/libs/picturefill/3.0.3/picturefill.min.js',
],
ServiceWorker: {
entry: './sw-handler.js',
publicPath: '/sw.js',
output: '../../../../sw.js',
},
AppCache: {
publicPath: '/appcache/',
directory: '../../../../appcache/',
// TODO adjust to your needs
FALLBACK: {
'/sample-page': '/',
'/contact': '/',
},
},
autoUpdate: true,
// TODO adjust to your needs
cacheMaps: [
{
match: /(\/sample-page|\/contact)\/?$/,
to: '/',
requestTypes: ['navigate'],
},
],
}),
],
};