-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
58 lines (56 loc) · 1.53 KB
/
webpack.config.babel.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
import path from 'path';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import nodeExternals from 'webpack-node-externals';
import NodemonPlugin from 'nodemon-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin';
import ESLintPlugin from 'eslint-webpack-plugin';
const config = (env, argv) => {
// const isProduction = argv.mode === "production";
return {
entry: [path.resolve(__dirname, 'src')],
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: 'app.js'
},
plugins: [
new CleanWebpackPlugin(),
new ESLintPlugin({
extensions: ['js', 'jsx', 'ts', 'tsx']
}),
new NodemonPlugin({
watch: [
path.resolve(__dirname, 'src'),
path.resolve('.env'),
path.resolve('package.json')
],
ignore: ['./node_modules'],
verbose: true,
delay: '1000'
}),
new CopyPlugin({ patterns: [{ from: '.env' }] })
],
target: 'node',
node: {
// Need this when working with express, otherwise the build fails
__dirname: true, // if you don't put this is, __dirname
__filename: false // and __filename return blank or /
},
externals: [nodeExternals()], // Need this to avoid error when working with Express
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
stats: {
warnings: true
}
};
};
export default config;