-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.config.js
98 lines (97 loc) · 2.65 KB
/
webpack.prod.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
const path = require("path");
const autoprefixer = require("autoprefixer");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const SWPrecacheWebpackPlugin = require("sw-precache-webpack-plugin");
var glob = require("glob");
module.exports = {
devtool: "cheap-module-source-map",
entry: './docx/index.js',
output: {
path: path.resolve(__dirname, "build"),
filename: "[name].js",
chunkFilename: "[id].js",
publicPath: "/"
},
resolve: {
extensions: [".js", ".jsx"],
alias: {
COMPONENT: path.resolve(__dirname, "component"),
PAGES: path.resolve(__dirname, "docx/pages")
}
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/
},
{
test: /\.(s*)css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader" // translates CSS into CommonJS
// options: {
// importLoaders: 1,
// modules: true,
// localIdentName: "[name]_[local]_[hash:base64:5]"
// }
},
{ loader: "sass-loader" },
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: () => [
autoprefixer({
browsers: ["> 1%", "last 2 versions"]
})
]
}
}
]
})
},
{
test: /\.(png|jpe?g|gif|svg)$/,
use: [
{
loader: 'file-loader?limit=8000&name=images/[name].[ext]'
}
]
}
]
},
devServer: {
stats: "errors-only",
historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
template: __dirname + "/index.html",
filename: "index.html",
inject: "body"
}),
new webpack.optimize.UglifyJsPlugin(),
new ExtractTextPlugin({ filename: "style.bundle.css" }),
new SWPrecacheWebpackPlugin({
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: "service-worker.js",
logger(message) {
if (message.indexOf("Total precache size is") === 0) {
// This message occurs for every build and is a bit too noisy.
return;
}
console.log(message);
},
minify: true,
navigateFallback: __dirname + "/index.html",
navigateFallbackWhitelist: [/^(?!\/__).*/],
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/]
})
]
};