-
Notifications
You must be signed in to change notification settings - Fork 394
Expand file tree
/
Copy pathwebpack-tools.config.js
More file actions
72 lines (68 loc) · 2.01 KB
/
webpack-tools.config.js
File metadata and controls
72 lines (68 loc) · 2.01 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
const configureWebpackForTerriaJS = require("./configureWebpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require("path");
const { IgnorePlugin } = require("webpack");
module.exports = function () {
const devMode = true;
const config = {
mode: devMode ? "development" : "production",
entry: {
generateDocs: path.resolve(__dirname, "generateDocs.ts"),
generateCatalogIndex: path.resolve(__dirname, "generateCatalogIndex.ts")
},
output: {
path: path.resolve(__dirname, "..", "build"),
filename: "[name].js",
sourcePrefix: "", // to avoid breaking multi-line string literals by inserting extra tabs.
globalObject: "(self || window)" // to avoid breaking in web worker (https://github.com/webpack/webpack/issues/6642)
},
target: "node",
resolve: {
alias: {},
modules: ["node_modules"],
extensions: [".ts", ".js", ".jsx", ".tsx", ".json"]
},
externals: {
vue: "vue"
},
plugins: [
new MiniCssExtractPlugin({
filename: "TerriaJS.css",
ignoreOrder: true
}),
// This is needed for a jsdom issue
new IgnorePlugin({
resourceRegExp: /canvas/,
contextRegExp: /jsdom$/
})
]
};
const babelLoader = {
loader: "babel-loader",
options: {
cacheDirectory: true,
sourceMaps: !!devMode,
presets: [
["@babel/preset-react", { runtime: "automatic" }],
["@babel/preset-typescript", { allowNamespaces: true }]
],
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
"babel-plugin-styled-components"
],
assumptions: {
setPublicClassFields: false
}
}
};
const terriaJSBasePath = path.dirname(require.resolve("../package.json"));
const jsExtraPaths = [path.resolve(terriaJSBasePath, "test")];
return configureWebpackForTerriaJS({
terriaJSBasePath,
jsExtraPaths,
config,
devMode,
MiniCssExtractPlugin,
babelLoader
});
};