forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
98 lines (97 loc) · 3.67 KB
/
webpack.config.js
File metadata and controls
98 lines (97 loc) · 3.67 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
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 FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
const webpack = require("webpack");
module.exports = {
mode: "production",
devtool: "source-map",
entry: {
main: "./web/htdocs/js/index.js",
mobile: "./web/htdocs/js/mobile.js",
side: "./web/htdocs/js/side_index.js",
themes: [
"./web/htdocs/themes/facelift/theme.scss",
"./web/htdocs/themes/classic/theme.scss",
],
},
output: {
path: path.resolve(__dirname, "web/htdocs/js"),
filename: "[name]_min.js",
publicPath: "js",
// Keep this until we have cleaned up our JS files to work as modules and changed all call sites
// from HTML code to work with the modules. Until then we need to keep the old behaviour of loading
// all JS code in the global namespace
libraryTarget: "window",
libraryExport: "default"
},
resolve: {
modules: [
"node_modules",
path.resolve(__dirname, "web/htdocs/js/modules"),
path.resolve(__dirname, "web/htdocs/js/modules/node_visualization"),
path.resolve(__dirname, "enterprise/web/htdocs/js/modules"),
]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
}
}
},
// needed for theme CSS files
{
test: /\.scss$/,
use: [
// 5. Write to theme specific file
{
loader: "file-loader",
options: {
regExp: /\/([a-z0-9_-]+)\/([a-z0-9_-]+)\.scss$/,
name: "../themes/[1]/[2].css"
}
},
// 4. Extract CSS definitions from JS wrapped CSS
{
loader: "extract-loader"
},
// 3. Interpret and resolve @import / url()
{
loader: "css-loader",
options: {
url: false,
importLoaders: 2
},
},
// 2. Some postprocessing of CSS definitions (see postcss.config.js)
// - add browser vendor prefixes https://github.com/postcss/autoprefixer
// - minifies CSS with https://github.com/jakubpawlowicz/clean-css
{
loader: "postcss-loader"
},
// 1. Transform sass definitions into CSS
{
loader: "sass-loader",
options: {
// Hand over build options from webpack to SASS
data: "$ENTERPRISE: " + process.env.ENTERPRISE + ";\n"
+ "$MANAGED: " + process.env.MANAGED + ";",
"includePaths": ["node_modules"],
// See https://github.com/sass/node-sass/blob/master/README.md#options
outputStyle: "expanded",
precision: 10
}
}
]
},
]
},
plugins: [
new FixStyleOnlyEntriesPlugin(),
new webpack.EnvironmentPlugin(["ENTERPRISE", "MANAGED"]),
]
};