-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack-backend.js
55 lines (52 loc) · 1.6 KB
/
webpack-backend.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
var webpack = require('webpack')
var path = require('path')
var fs = require('fs')
// thanks to https://archive.jlongster.com/Backend-Apps-with-Webpack--Part-I
var nodeModules = {}
fs.readdirSync('node_modules')
.filter(function (x) {
return ['.bin'].indexOf(x) === -1
})
.forEach(function (mod) {
nodeModules[mod] = 'commonjs ' + mod
})
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: './app/start.js',
target: 'node',
output: {
path: path.join(__dirname, 'build'),
filename: 'backend.js',
},
externals: nodeModules,
module: {
rules: [
{
test: /\.js$|\.jsx$/,
// to include components from packages in node_modules they must be included and excluded
include: [path.resolve('node_modules/civil-pursuit'), path.resolve('.')],
// they also must be exclude it from the exclusions:
exclude: /node_modules\/(?!(civil-pursuit)\/).*/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react', ['@babel/preset-env', { targets: { node: '16' } }]],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-react-inline-elements',
],
},
},
],
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [new webpack.BannerPlugin('require("source-map-support").install();', { raw: true, entryOnly: false })],
}