forked from topcoder-platform/micro-frontends-onboarding-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
109 lines (106 loc) · 3.22 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
102
103
104
105
106
107
108
109
/* global __dirname 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 _ = require("lodash");
const config = require("config");
const cssLocalIdent =
process.env.APPMODE === "production"
? "[hash:base64:6]"
: "onboarding_[path][name]___[local]___[hash:base64:6]";
module.exports = (webpackConfigEnv) => {
const defaultConfig = singleSpaDefaults({
orgName: "topcoder",
projectName: "micro-frontends-onboarding-app",
webpackConfigEnv,
});
return webpackMerge.smart(defaultConfig, {
output: {
// path: path.resolve(__dirname, 'dist'),
publicPath: "onboarding-app",
},
// modify the webpack config however you'd like to by adding to this object
module: {
rules: [
{
/* Loads SCSS stylesheets. */
test: /\.scss/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
modules: {
localIdentName: cssLocalIdent,
auto: true,
},
},
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [autoprefixer],
},
},
},
"resolve-url-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.svg$/,
oneOf: [
{
exclude: [/node_modules/],
loader: "babel-loader",
},
{
exclude: [/node_modules/],
loader: require.resolve("file-loader", { paths: [__dirname] }),
},
],
},
{
/* Loads raster images */
test: /\.(gif|jpe?g|png)$/,
exclude: [/node_modules/, /[/\\]assets[/\\]fonts/],
loader: "file-loader",
options: {
outputPath: "icons",
},
},
],
},
resolve: {
alias: {
styles: path.resolve(__dirname, "src/styles"),
components: path.resolve(__dirname, "src/components"),
hooks: path.resolve(__dirname, "src/hooks"),
utils: path.resolve(__dirname, "src/utils"),
constants: path.resolve(__dirname, "src/constants"),
services: path.resolve(__dirname, "src/services"),
hoc: path.resolve(__dirname, "src/hoc"),
},
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
..._.mapValues(config, (value) => JSON.stringify(value)),
APPENV: JSON.stringify(process.env.APPENV),
APPMODE: JSON.stringify(process.env.APPMODE),
},
}),
// 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$/),
],
});
};