-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
47 lines (46 loc) · 1.1 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
42
43
44
45
46
47
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const webpack = require('webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
/**
* @type {import('webpack').ConfigurationFactory}
*/
module.exports = (env = {}) => {
const { dev } = env;
return {
mode: dev ? 'development' : 'production',
entry: {
index: ['./src/index.ts'],
},
resolve: {
extensions: ['.ts', '.mjs', '.js', '.json'],
alias: {
semver$: 'semver/preload',
},
},
output: { libraryTarget: 'commonjs2' },
devtool: 'none',
target: 'node',
module: {
rules: [
{
exclude: /node_modules/,
test: /\.ts$/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
},
},
],
},
plugins: [
new CleanWebpackPlugin(),
new webpack.NormalModuleReplacementPlugin(/iconv-loader$/, 'lodash/noop'),
new ForkTsCheckerWebpackPlugin(),
],
watchOptions: {
ignored: /\.test\.ts$/,
},
};
};