-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
63 lines (56 loc) · 1.63 KB
/
webpack.prod.js
File metadata and controls
63 lines (56 loc) · 1.63 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
// Merge Webpack Config Files for better file organisation.
const Merge = require("webpack-merge");
// Bundles (CSS) to own CSS file rather than embedded in CSS.
const ExtractTextPlugin = require("extract-text-webpack-plugin");
// Purges unused CSS (Great for use with a style framework like Tailwind)
const PurgecssPlugin = require("purgecss-webpack-plugin");
// Wipes docs directory on recompiling, keeping the directory clean.
const CleanWebpackPlugin = require("clean-webpack-plugin");
// Convert variable names to short names to reduce file size
// Uglyifying is now on by default for the production mode.
const common = require("./webpack.common.js");
const webpack = require("webpack");
const path = require("path");
const glob = require("glob");
class TailwindExtractor {
static extract(content) {
return content.match(/[A-z0-9-:\/]+/g) || [];
}
}
module.exports = Merge(common, {
mode: "production",
devtool: "source-map",
output: {
path: path.resolve(__dirname, "docs"),
filename: "[name].[chunkhash:8].js",
chunkFilename: "[name].[chunkhash:8].js",
publicPath: "./"
},
plugins: [
new ExtractTextPlugin("[name].[hash:8].css"),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
})
],
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
importLoaders: 1
}
},
"postcss-loader"
]
})
}
]
}
});