-
Notifications
You must be signed in to change notification settings - Fork 26
/
webpack.config.js
109 lines (104 loc) · 2.61 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
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', '.gjs', '.gts'],
},
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/examples/basic/index.ts',
rehydration: './packages/examples/rehydration/index.ts',
partialRehydration: './packages/examples/partial-rehydration/index.ts',
nodeTests: './tests/node.ts',
tests: './tests/index.ts',
},
module: {
rules: [
{
test: /(\.ts|\.js|\.gts|\.gjs)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@glimmerx/babel-preset', '@babel/preset-typescript', '@babel/preset-env'],
},
},
'@glimmerx/webpack-loader',
],
},
],
},
};
const nodeConfig = {
...commonConfig,
devtool: false,
entry: {
rehydrationNodeServer: './packages/examples/rehydration/server.ts',
partialRehydrationNodeServer: './packages/examples/partial-rehydration/server.ts',
},
externals: {
...commonConfig.externals,
'@glimmer/validator': '@glimmer/validator',
},
output: {
...commonConfig.output,
libraryTarget: 'umd',
},
target: 'node',
module: {
rules: [
{
test: /(\.ts|\.js|\.gts|\.gjs)$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'@glimmerx/babel-preset',
'@babel/preset-typescript',
[
'@babel/preset-env',
{
targets: {
node: true,
},
},
],
],
},
},
'@glimmerx/webpack-loader',
],
},
],
},
};
module.exports = [nodeConfig, browserConfig];