-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.dev.js
75 lines (69 loc) · 1.86 KB
/
webpack.config.dev.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
const webpack = require("webpack")
const path = require("path")
const R = require("ramda")
const BundleTracker = require("webpack-bundle-tracker")
const { config } = require(path.resolve("./webpack.config.shared.js"))
const {
CKEditorTranslationsPlugin,
} = require("@ckeditor/ckeditor5-dev-translations")
const hotEntry = (host, port) =>
`webpack-hot-middleware/client?path=http://${host}:${port}/__webpack_hmr&timeout=20000&reload=true`
const insertHotReload = (host, port, entries) =>
R.map(
R.compose(R.flatten, (v) => [v].concat(hotEntry(host, port))),
entries,
)
const devConfig = Object.assign({}, config, {
context: __dirname,
mode: "development",
devtool: "inline-source-map",
output: {
path: path.resolve("./static/bundles/"),
filename: "[name].js",
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new BundleTracker({ filename: "./webpack-stats.json" }),
new CKEditorTranslationsPlugin({
language: "en",
addMainLanguageTranslationsToAllAssets: true,
}),
new webpack.DefinePlugin({
RELEASE_YEAR: JSON.stringify(new Date().getUTCFullYear()),
}),
],
optimization: {
moduleIds: "named",
splitChunks: {
name: "common",
minChunks: 2,
},
emitOnErrors: true,
},
})
devConfig.module.rules = [
...config.module.rules,
{
// this regex is necessary to explicitly exclude ckeditor stuff
test: /static\/scss\/.+(\.css$|\.scss$)/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader?url=false" },
{ loader: "postcss-loader" },
{
loader: "sass-loader",
options: {
sassOptions: { quietDeps: true },
},
},
],
},
]
const makeDevConfig = (host, port) =>
Object.assign({}, devConfig, {
entry: insertHotReload(host, port, devConfig.entry),
})
module.exports = {
makeDevConfig,
devConfig,
}