forked from module-federation/module-federation-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient-ssr.js
52 lines (50 loc) · 1.63 KB
/
client-ssr.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
const { AngularWebpackPlugin } = require('@ngtools/webpack');
const { resolve } = require('path');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlugin;
module.exports = (env = {}) => {
const buildFolder = resolve('./dist/server');
return {
entry: ['./src/main.ts'],
mode: 'production',
resolve: {
mainFields: ['browser', 'module', 'main'],
extensions: ['.ts', '.js'],
},
output: {
filename: '[name].js',
path: resolve(__dirname, buildFolder),
chunkFilename: '[id].[chunkhash].js',
libraryTarget: 'commonjs2',
},
target: 'async-node',
plugins: [
new ProgressPlugin(),
new ModuleFederationPlugin({
name: 'clientApp',
filename: 'remoteEntry.js',
library: { type: 'commonjs2' },
exposes: {
'./Component': './src/app/client-cities/client-city/client-city.component.ts',
'./Module': './src/app/client-cities/client-cities.module.ts',
},
shared: [
{ '@angular/core': { singleton: true, eager: true } },
{ '@angular/common': { singleton: true, eager: true } },
{ '@angular/router': { singleton: true, eager: true } },
],
}),
new AngularWebpackPlugin({
entryModule: resolve(__dirname, '../src/app/app.module#AppModule'),
tsConfigPath: './tsconfig.app.json',
platform: 1,
jitMode: true,
skipCodeGeneration: true,
directTemplateLoading: false,
}),
],
module: {
rules: [...require('./_loaders')],
},
};
};