This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
76 lines (73 loc) · 2.08 KB
/
webpack.prod.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
const webpack = require("webpack");
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
var BUILD_DIR = path.resolve(__dirname, "./build");
var APP_DIR = path.resolve(__dirname, "./src/client");
const config = {
entry: {
main: APP_DIR + "/index.js"
},
output: {
filename: "js/bundle.js",
path: BUILD_DIR,
chunkFilename: "js/[name].min.js"
},
optimization: {
minimizer: [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true, // set to true if you want JS source maps
uglifyOptions: {
output: {
comments: false
}
}
}),
new OptimizeCSSAssetsPlugin({})
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "css/[name].css",
chunkFilename: "css/[id].css"
})
],
module: {
rules: [
{
test: /\.(jsx|js)?$/,
use: [
{
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: [
"@babel/preset-env",
"@babel/preset-react"
] // Transpiles JSX and ES6
}
}
]
},
{
test: /\.scss$/,
use: [{
loader: MiniCssExtractPlugin.loader
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
includePaths: ["node_modules/tachyons-sass/"]
}
}]
}
]
},
mode: "production",
target: "web"
};
module.exports = config;