This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
webpack.config.js
103 lines (98 loc) · 2.51 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
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const commonConfig = {
mode: 'development',
externals: {
fs: 'fs',
},
resolve: {
plugins: [
new TsconfigPathsPlugin({
mainFields: ['module', 'main'],
}),
],
extensions: ['.ts', '.js'],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
writeToDisk: true,
before: (app) => {
app.get('/rehydration', (req, res) => {
const { default: handler } = require('./dist/rehydrationNodeServer.bundle.js');
handler(req, res, './rehydration.bundle.js');
});
app.get('/partial-rehydration', (req, res) => {
const { default: handler } = require('./dist/partialRehydrationNodeServer.bundle.js');
handler(req, res, './partialRehydration.bundle.js');
});
},
},
};
const browserConfig = {
...commonConfig,
entry: {
app: './packages/example-apps/basic/index.ts',
rehydration: './packages/example-apps/rehydration/index.ts',
partialRehydration: './packages/example-apps/partial-rehydration/index.ts',
tests: './test/index.ts',
nodeTests: './test/node.ts',
},
module: {
rules: [
{
test: /(\.ts|\.js)$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@glimmer/babel-preset', '@babel/preset-typescript', '@babel/preset-env'],
},
},
},
],
},
};
const nodeServerConfig = {
...commonConfig,
devtool: false,
entry: {
rehydrationNodeServer: './packages/example-apps/rehydration/server.ts',
partialRehydrationNodeServer: './packages/example-apps/partial-rehydration/server.ts',
},
output: {
...commonConfig.output,
libraryTarget: 'umd',
},
externals: {
// Remove once we have new glimmer-vm version published. The duplicate version is from linking issues
'@glimmer/validator': '@glimmer/validator',
},
target: 'node',
module: {
rules: [
{
test: /(\.ts|\.js)$/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@glimmer/babel-preset',
'@babel/preset-typescript',
[
'@babel/preset-env',
{
targets: {
node: true,
},
},
],
],
},
},
},
],
},
};
module.exports = [nodeServerConfig, browserConfig];