-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
55 lines (51 loc) · 1.37 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
52
53
54
55
const TerserPlugin = require('terser-webpack-plugin');
const { resolve } = require('upath');
var webpack = require('webpack');
const ResolveTypeScriptPlugin = require('resolve-typescript-plugin');
/** @type {webpack.Configuration[]} */
const config = [];
function gen(fn) {
/** @type {webpack.Configuration} */
const config = {
entry: './src/index.ts',
watchOptions: {
aggregateTimeout: 10000,
poll: 1000,
followSymlinks: true,
ignored: /node_modules|tmp|tests|typings|dist/
},
plugins: [new webpack.HotModuleReplacementPlugin()],
module: {
rules: [
{
test: /\.(ts|js)?$/,
use: 'ts-loader',
exclude: /node_modules|.test.(ts|js)$/
}
]
},
resolve: {
extensions: ['.ts', '.js'],
plugins: [new ResolveTypeScriptPlugin()],
fallback: {
crypto: require.resolve('crypto-browserify'),
path: require.resolve('path-browserify'),
fs: false
}
},
output: {
filename: fn + '.js',
path: resolve(__dirname, 'dist'),
sourceMapFilename: fn + '.map',
library: 'safelinkify',
libraryTarget: 'umd',
globalObject: 'this'
},
mode: fn.includes('.min') ? 'production' : 'development'
};
return config;
}
['bundle', 'bundle.min'].forEach(function (key) {
config.push(gen(key));
});
module.exports = config;