-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
81 lines (80 loc) · 2.57 KB
/
webpack.common.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
77
78
79
80
81
const cwd = process.cwd();
const path = require("path");
const webpack = require(require.resolve("webpack", { paths: [cwd] }));
const HiveInterfaceToObjectPlugin = require("@combeenation/webpack-hive-itf-to-obj-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
/**
* Production settings
* - "Repo wide" dev specific overrides can be found in "webpack.global.dev.js"
* - Further project specific overrides can be found in "project/folder/webpack.dev" & "project/folder/webpack.prod"
*
* @param {string} mainFileName
* @return {webpack.Configuration}
*/
module.exports = function createProductionCfgn(mainFileName) {
return {
mode: "production",
devtool: "source-map",
output: {
path: path.resolve(cwd, "dist"),
filename: "cfgr.js",
},
entry: ["whatwg-fetch", "./src/" + mainFileName],
plugins: [
new HiveInterfaceToObjectPlugin(),
new ESLintPlugin(),
// watchOptions.ignored not working due to backslashes in the path (Windows)
new webpack.WatchIgnorePlugin({ paths: [/node_modules/, /typings-generated-objs/] }),
],
performance: {
maxEntrypointSize: 800 * 1000,
maxAssetSize: 800 * 1000,
},
module: {
rules: [
{
test: /\.js$/,
include: [/src/],
use: {
loader: "babel-loader",
options: {
plugins: [
require.resolve("babel-plugin-transform-class-properties"),
require.resolve("@babel/plugin-proposal-optional-chaining"),
require.resolve("@babel/plugin-proposal-nullish-coalescing-operator"),
],
presets: [
[
require.resolve("@babel/preset-env"),
{
targets: {
ie: "11",
safari: "10",
},
},
],
],
},
},
},
{
test: /\.js$/,
loader: "ts-loader",
include: [/src/],
exclude: [/node_modules/],
options: {
context: cwd,
configFile: path.resolve(cwd, "tsconfig.json"),
},
},
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre",
// temporarily disable shapediver source maps
exclude: [path.resolve(cwd, "node_modules/@shapediver"), path.resolve(cwd, "node_modules/@sentry")],
},
],
},
};
};