-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
87 lines (85 loc) · 2.67 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
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const { merge } = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa-ts");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
require("dotenv").config({
path: require("find-config")(".env"),
});
module.exports = (webpackConfigEnv, argv) => {
const orgName = "samply";
const defaultConfig = singleSpaDefaults({
orgName,
projectName: "root-config",
webpackConfigEnv,
argv,
disableHtmlGeneration: true,
});
return merge(defaultConfig, {
// Add devServer configuration here to ensure static files are served correctly
devServer: {
static: {
directory: path.join(__dirname, 'dist'), // Serve static files from dist directory
},
historyApiFallback: {
rewrites: [
{
from: /^\/libs\/.*/,
to: '/libs/index.html', // Ensure that /libs paths are handled by Webpack
},
],
},
},
plugins: [
new HtmlWebpackPlugin({
inject: false,
template: "src/index.ejs",
templateParameters: {
isLocal: webpackConfigEnv && webpackConfigEnv.isLocal,
orgName,
},
favicon: "src/favicon.ico"
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, 'node_modules/regenerator-runtime/runtime.js'),
to: 'libs/runtime.js'
},
{
from: path.resolve(__dirname, 'node_modules/single-spa/lib/system/single-spa.min.js'),
to: 'libs/single-spa.min.js'
},
{
from: path.resolve(__dirname, 'node_modules/zone.js/fesm2015/zone.js'),
to: 'libs/zone.js'
},
{
from: path.resolve(__dirname, 'node_modules/systemjs/dist/system.min.js'),
to: 'libs/system.min.js'
},
{
from: path.resolve(__dirname, 'node_modules/systemjs/dist/system.js'),
to: 'libs/system.js'
},
{
from: path.resolve(__dirname, 'node_modules/systemjs/dist/extras/amd.min.js'),
to: 'libs/amd.min.js'
},
{
from: path.resolve(__dirname, 'node_modules/systemjs/dist/extras/amd.js'),
to: 'libs/amd.js'
},
{
from: path.resolve(__dirname, 'node_modules/import-map-overrides/dist/import-map-overrides.js'),
to: 'libs/import-map-overrides.js'
}
]
}),
new webpack.DefinePlugin({
"process.env": JSON.stringify(process.env),
}),
],
});
};