-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
41 lines (39 loc) · 1.07 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
const path = require('path');
const webpackNodeExternals = require('webpack-node-externals');
module.exports = function ({target}) {
const webTSConfig = {
module: 'ESNEXT',
target: 'ES2015',
};
const nodeTSConfig = {
module: 'commonjs',
target: 'ES2018',
types: ['node'],
};
return {
target,
entry: path.join(__dirname, `src/${target}-entrypoint.tsx`),
output: {
path: path.join(__dirname, 'build', target === 'web' ? 'public' : ''),
filename: `${target}.bundle.js`,
publicPath: path.join('/', 'static/'),
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
externals: target === 'node' ? [webpackNodeExternals()] : [],
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
compilerOptions: target === 'web' ? webTSConfig : nodeTSConfig,
onlyCompileBundledFiles: true,
},
},
]
},
}
};