-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.server.ts
More file actions
93 lines (88 loc) · 2.69 KB
/
Copy pathwebpack.config.server.ts
File metadata and controls
93 lines (88 loc) · 2.69 KB
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
/**
* Copyright 2016 DanceDeets.
*/
import webpack from 'webpack';
import path from 'path';
import { argv as env } from 'yargs';
const prod = !(env as { debug?: boolean }).debug;
// Bundle all dependencies into the output - no node_modules needed at runtime
// This dramatically reduces deploy size (from 188k files to just the bundles)
// mjml is kept external because it has complex ESM/dynamic requires that webpack 3 can't handle
const externals: Record<string, string> = {
mjml: 'commonjs mjml',
};
const config: webpack.Configuration = {
entry: {
brackets: './assets/js/brackets.js',
calendar: './assets/js/calendar.js',
classResults: './assets/js/classResults.js',
event: './assets/js/event.js',
eventSearchResults: './assets/js/eventSearchResults.js',
homepageReact: './assets/js/homepageReact.js',
mailAddEvent: './assets/js/mailAddEvent.js',
mailWeeklyNew: './assets/js/mailWeeklyNew.js',
mailNewUser: './assets/js/mailNewUser.js',
renderServer: './node_server/renderServer.js',
topic: './assets/js/topic.js',
tutorial: './assets/js/tutorial.js',
tutorialCategory: './assets/js/tutorialCategory.js',
weeklyMail: './assets/js/weeklyMail.js',
},
output: {
path: path.join(__dirname, 'dist/js-server'),
filename: '[name].js',
libraryTarget: 'commonjs2', // Export as module.exports for require()/eval()
},
devtool: prod ? 'source-map' : 'cheap-eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(prod ? 'production' : ''),
},
}),
],
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
target: 'node',
externals,
module: {
rules: [
// Note: eslint-loader and shebang-loader removed - not needed for server builds
{
test: /\.jsx?$/,
exclude: /node_modules(?!\/dancedeets-common)/,
use: {
loader: 'babel-loader',
options: {
babelrc: false, // Ignore .babelrc files in source directories
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
'@babel/preset-react',
],
plugins: ['@babel/plugin-transform-flow-strip-types'],
},
},
},
// Server-side doesn't need actual CSS/images/fonts - use null-loader to ignore them
{
test: /\.(png|gif|jpg|jpeg|svg)$/,
loader: 'null-loader',
},
{
test: /\.s?css$/,
loader: 'null-loader',
},
{
test: /\.(ttf|otf|eot|woff(2)?)(\?[a-z0-9=.]+)?$/,
loader: 'null-loader',
},
],
},
};
export default config;