-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.server.js
executable file
·60 lines (59 loc) · 1.44 KB
/
webpack.server.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
const path = require('path');
const webpackNodeExternals = require('webpack-node-externals')
const webpack = require('webpack')
const dotenv = require('dotenv') // >> when process is undefined
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: 'development',
target: 'node', // most impportant thing >> when global is undefined
entry: './server.js',
output: {
filename: "bundle.js",
path: path.resolve(__dirname, 'build'),
publicPath: '/build'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: '/node_modules/',
options: {
presets: [
"@babel/preset-env", "@babel/preset-react"
],
},
},
{
test: /\.svg$/,
loader: 'svg-inline-loader'
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif|tiff|ico)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
publicPath: '/'
}
}
]
},
]
},
resolve: {
extensions: ['.mjs', '.js', '.jsx', '.css']
},
plugins: [
new webpack.DefinePlugin({
'process.env': JSON.stringify(dotenv.config().parsed)
}),
new MiniCssExtractPlugin()
],
externals: [webpackNodeExternals()]
}