This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwebpack.config.js
92 lines (88 loc) · 2.89 KB
/
webpack.config.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
82
83
84
85
86
87
88
89
90
91
92
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const Path = require("path");
var env = process.env.ENV || "local";
var buildNumber = process.env.BUILD_NUMBER || "1";
var SiteConfig = require("./shared/config/SiteConfig.js")(env, buildNumber);
var cssConfig = SiteConfig.toSCSSEnv();
const isDevEnv = /^(local|dev|develop)$/gi.test(env);
const sourceMapOptions = isDevEnv ? "eval-cheap-module-source-map" : false;
const mode = isDevEnv ? "development" : "production";
var config = {
entry: ["./client/app.js", "./scss/main.scss"],
output: {
filename: "bundle.js",
path: __dirname + "/dist",
},
resolve: {
alias: {
PIXI: Path.resolve(__dirname, "node_modules/pixi.js/"),
},
},
mode: mode,
devtool: sourceMapOptions,
externals: {
three: "THREE",
},
module: {
rules: [
{
test: /.jsx?$/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/react", ["@babel/env", { "targets": "defaults" }]],
plugins: ["@babel/plugin-transform-spread"]
},
},
],
exclude: Path.resolve(__dirname, "node_modules")
},
{
test: /forge-dataviz-iot-react-component.*.jsx?$/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/react", ["@babel/env", { "targets": "defaults" }]],
plugins: ["@babel/plugin-transform-spread"]
}
},
],
exclude: Path.resolve(__dirname, "node_modules", "forge-dataviz-iot-react-components", "node_modules"),
},
{
test: /\.(css|sass|scss)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader"
},
{
loader: "sass-loader",
options: {
additionalData: cssConfig
}
}
]
},
{
test: /\.svg$/i,
use: {
loader: "svg-url-loader",
options: {
// make loader to behave like url-loader, for all svg files
encoding: "base64",
},
},
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "[name].bundle.css"
}),
require("./tools/WebpackDefines.js"),
],
};
module.exports = config;