forked from brendanashworth/generate-password
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
51 lines (46 loc) · 1.34 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
48
49
50
51
const path = require('path');
// const webpack = require('webpack');
const base = require('./webpack.baseconfig');
const config = {
entry: ['./src/index.ts'],
output: {
filename: `${base.libName}.bundle.js`,
chunkFilename: '[name].js',
path: path.resolve(__dirname, './dist'),
publicPath: path.resolve(__dirname, './dist'),
library: base.libName,
libraryTarget: 'umd',
globalObject: 'this' // for node js import
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx' ],
modules: ['node_modules'],
fallback:{
'crypto': false
}
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: 'webpack.tsconfig.json', // for tree shaking https://mizchi.dev/202006101314-switch-tsconfig-on-webpack
},
},
exclude: path.join(__dirname, 'node_modules') // exclude: /node_modules/
},
],
}
};
module.exports = (env, argv) => {
config.mode = (typeof argv.mode !== 'undefined' && argv.mode === 'production') ? argv.mode : 'development';
if (config.mode === 'production') console.log('Webpack for production');
else{
console.log('Webpack for development');
config.devtool = 'inline-source-map'; // add inline source map
}
return config;
};