-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
41 lines (38 loc) · 936 Bytes
/
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
import path from 'path';
import { fileURLToPath } from 'url';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import nodeExternals from 'webpack-node-externals';
const devMode = process.env.NODE_ENV !== 'production';
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
export default {
mode: devMode ? 'development' : 'production',
watch: devMode,
entry: path.resolve(dirname, 'src/index.js'),
output: {
filename: '[name].bundle.js',
path: path.resolve(dirname, 'dist'),
chunkFormat: 'module',
library: {
type: 'module',
},
},
externalsPresets: { node: true },
externals: [nodeExternals({ importType: 'module' })],
experiments: {
outputModule: true,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader'],
resolve: {
fullySpecified: false,
},
},
],
},
plugins: [new CleanWebpackPlugin()],
};