forked from mitodl/ocw-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
60 lines (57 loc) · 1.52 KB
/
webpack.config.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
const webpack = require("webpack")
const path = require("path")
const BundleTracker = require("webpack-bundle-tracker")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const { config } = require(path.resolve("./webpack.config.shared.js"))
const CKEditorWebpackPlugin = require("@ckeditor/ckeditor5-dev-webpack-plugin")
const prodConfig = Object.assign({}, config)
prodConfig.module.rules = [
...config.module.rules,
{
// this regex is necessary to explicitly exclude ckeditor stuff
test: /static\/scss\/.+(\.css$|\.scss$)/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
"css-loader?url=false",
"postcss-loader",
{
loader: "sass-loader",
options: {
sassOptions: { quietDeps: true },
},
}
]
}
]
module.exports = Object.assign(prodConfig, {
context: __dirname,
mode: "production",
output: {
path: path.resolve("./static/bundles/"),
filename: "[name]-[chunkhash].js",
chunkFilename: "[id]-[chunkhash].js",
crossOriginLoading: "anonymous"
},
plugins: [
new BundleTracker({
filename: "./webpack-stats.json"
}),
new webpack.LoaderOptionsPlugin({
minimize: true
}),
new webpack.optimize.AggressiveMergingPlugin(),
new MiniCssExtractPlugin({
filename: "[name]-[contenthash].css"
}),
new CKEditorWebpackPlugin({
language: "en",
addMainLanguageTranslationsToAllAssets: true
})
],
optimization: {
minimize: true
},
devtool: "source-map"
})