-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.dev.config.js
112 lines (110 loc) · 2.91 KB
/
webpack.dev.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
const path = require('path');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const { ModuleFederationPlugin } = require('webpack').container;
const sources = path.resolve(__dirname, '../resources/');
const output = path.resolve(__dirname, '../public/');
const config = {
mode: 'development',
devtool: 'inline-source-map',
entry: {
app: `${sources}/js/app.js`,
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
targets: {
browsers: [
'> 0.25% and supports es6-module',
'not dead',
'Firefox ESR',
],
},
corejs: {
// core-js package version
// see: https://babeljs.io/docs/babel-preset-env#corejs
version: '3.39',
proposals: true,
},
},
],
],
plugins: [['@babel/plugin-transform-runtime']],
},
},
},
],
},
optimization: {
splitChunks: {
chunks: 'all',
},
runtimeChunk: {
name: entrypoint => `runtime-${entrypoint.name}`,
},
},
experiments: {
outputModule: true,
},
plugins: [
new WebpackManifestPlugin({
fileName: 'asset-manifest.json',
publicPath: '/',
generate: (seed, files, entrypoints) => {
const manifestFiles = files.reduce((manifest, file) => {
manifest[file.name] = file.path;
return manifest;
}, seed);
const entrypointFiles = entrypoints['app'].filter(
fileName => !fileName.endsWith('.map')
);
return {
files: manifestFiles,
entrypoints: entrypointFiles,
};
},
}),
new WebpackNotifierPlugin({
title: 'Modern JS Webpack',
excludeWarnings: true,
alwaysNotify: true,
}),
new ModuleFederationPlugin({
name: 'host',
library: { type: 'module' },
filename: 'remoteEntry.js',
remotes: {
remote_bucket: 'https://mda.orion.net/design-area/remoteEntry.js',
// remote: 'http://localhost:3001/assets/remoteEntry.js',
},
}),
],
output: {
path: output,
filename: 'js/[name].[chunkhash].js',
chunkFilename: 'js/[name].[chunkhash].js',
publicPath: '/',
environment: {
arrowFunction: true,
bigIntLiteral: true,
const: true,
destructuring: true,
dynamicImport: true,
forOf: true,
module: true,
},
},
target: 'web',
};
module.exports = config;