forked from topcoder-platform/mfe-header
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
113 lines (109 loc) · 3.02 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
110
111
112
113
/* global __dirname */
const webpackMerge = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa-react");
const autoprefixer = require('autoprefixer');
const path = require('path')
const webpack = require('webpack')
module.exports = (webpackConfigEnv, options) => {
const defaultConfig = singleSpaDefaults({
orgName: "topcoder",
projectName: "micro-frontends-navbar-app",
webpackConfigEnv,
disableHtmlGeneration: true,
});
let cssLocalIdent;
if (options.mode === 'production') {
cssLocalIdent = '[hash:base64:6]';
} else {
cssLocalIdent = 'navbar_[path][name]___[local]___[hash:base64:6]';
}
// modify the webpack config however you'd like to by adding to this object
return webpackMerge.smart(defaultConfig, {
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: 'navbar',
},
module: {
rules: [
{
/* Loads svg images. */
test: /[/\\]assets[/\\]images[/\\].+\.svg$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
outputPath: 'images',
}
},
{
/* Loads image assets. */
test: /\.(gif|jpe?g|png)$/,
loader: 'file-loader',
options: {
outputPath: 'images',
}
},
{
/* Loads font resources from "src/assets/fonts" folder. */
test: /\.(eot|otf|svg|ttf|woff2?)$/,
include: [/src[/\\]assets[/\\]fonts/],
loader: 'file-loader',
options: {
outputPath: 'fonts',
}
},
{
/* Loads SCSS stylesheets. */
test: /\.scss/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: cssLocalIdent,
mode: 'local',
}
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [autoprefixer],
}
},
},
'resolve-url-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
}
]
},
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
APPENV: JSON.stringify(process.env.APPENV),
},
}),
],
resolve: {
alias: {
assets: path.resolve(__dirname, "src/assets"),
components: path.resolve(__dirname, "src/components"),
fonts: path.resolve(__dirname, "src/assets/fonts"),
styles: path.resolve(__dirname, "src/styles"),
handlebars: path.resolve(__dirname, 'node_modules/handlebars/dist/handlebars.min.js'),
},
symlinks: false,
},
devServer: {
port: 3001,
host: '0.0.0.0'
}
});
};