forked from topcoder-platform/micro-frontends-taas-admin-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
101 lines (96 loc) · 2.8 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
93
94
95
96
97
98
99
100
101
/* global __dirname */
/* global process */
const webpack = require("webpack");
const webpackMerge = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa-react");
const path = require("path");
const autoprefixer = require("autoprefixer");
const IS_DEV = process.env.APPMODE !== "production";
const cssLocalIdent = IS_DEV
? "taas_admin_[path][name]___[local]___[hash:base64:6]"
: "[hash:base64:6]";
const srcDir = path.resolve(__dirname, "src");
module.exports = (webpackConfigEnv) => {
const defaultConfig = singleSpaDefaults({
orgName: "topcoder",
projectName: "micro-frontends-taas-admin-app",
webpackConfigEnv,
});
return webpackMerge.smart(defaultConfig, {
output: {
publicPath: "/taas-admin-app",
},
// modify the webpack config however you'd like to by adding to this object
module: {
rules: [
{
test: /\.scss$/,
use: [
{ loader: "style-loader" },
{
loader: "css-loader",
options: {
modules: {
localIdentName: cssLocalIdent,
auto: true,
},
},
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [autoprefixer],
},
},
},
// { loader: "resolve-url-loader" },
{
loader: "sass-loader",
options: {
sourceMap: true,
sassOptions: {
outputStyle: IS_DEV ? "expanded" : "compressed",
precision: 8,
includePaths: [path.join(srcDir, "styles")],
},
},
},
],
},
{
test: /\.svg$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.(gif|jpg|png|svg)$/,
include: /.*assets[/\\]images.+/,
use: {
loader: "url-loader",
options: {
limit: 4096,
},
},
},
],
},
resolve: {
extensions: [".js", ".jsx", ".json", ".scss"],
modules: [srcDir, "node_modules"],
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
APPMODE: JSON.stringify(process.env.APPMODE),
APPENV: JSON.stringify(process.env.APPENV),
},
}),
// ignore moment locales to reduce bundle size by 64kb gzipped
// see solution details https://stackoverflow.com/questions/25384360/how-to-prevent-moment-js-from-loading-locales-with-webpack/25426019#25426019
new webpack.IgnorePlugin(/^\.[/\\]locale$/, /moment$/),
],
});
};