-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
webpack.base.config.js
68 lines (58 loc) · 1.42 KB
/
webpack.base.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
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require('path')
const dts = require('dts-bundle');
const defaultPlugins = () => [
new (require('remove-strict-webpack-plugin'))()
]
const baseConfig = () => {
return {
devtool: 'source-map',
output: {
globalObject: '(typeof self !== "undefined" ? self : this)', // make it works for both node and browser
libraryTarget: 'umd2',
library: ["Wenyan", "[name]"],
path: path.resolve(__dirname, 'dist'),
filename: '[name]/index.min.js',
},
plugins: defaultPlugins(),
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.wy$/i,
use: 'raw-loader',
},
],
},
}
};
var DtsBundlePlugin = (function () {
const dts = require('dts-bundle');
function DtsBundlePlugin(options){
if (options === void 0) { options = {}; }
this.options = options;
}
function _bundle(options) {
return () => dts.bundle(options);
}
DtsBundlePlugin.prototype.apply = function (compiler) {
const bundle = () => _bundle(this.options);
if (!!compiler.hooks) {
compiler.hooks.afterEmit.tap('DtsBundlePlugin', bundle());
} else {
compiler.plugin('done', bundle());
}
};
return DtsBundlePlugin;
})();
module.exports = {
baseConfig,
defaultPlugins,
DtsBundlePlugin
}