forked from uiwjs/uiw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.kktrc.ts
66 lines (63 loc) · 1.92 KB
/
.kktrc.ts
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
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import path from 'path';
export const loaderOneOf = [
require.resolve('@kkt/loader-less'),
];
export default (conf, options) => {
if (options.yargsArgs && options.yargsArgs.bundle) {
conf.devtool = false;
const regexp = /(HtmlWebpackPlugin|InlineChunkHtmlPlugin|InterpolateHtmlPlugin|MiniCssExtractPlugin|ManifestPlugin|GenerateSW|ForkTsCheckerWebpackPlugin)/;
conf.plugins = conf.plugins.map((item) => {
if (item.constructor && item.constructor.name && regexp.test(item.constructor.name)) {
return null;
}
return item;
}).filter(Boolean);
conf.entry = './src/index.ts';
conf.output = {
path: path.join(process.cwd(), 'dist'),
filename: 'uiw.js',
library: 'UIW',
libraryTarget: 'umd',
}
conf.externals = {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
},
}
if (options.yargsArgs && options.yargsArgs.mini) {
conf.output.filename = 'uiw.min.js';
conf.plugins = [
...conf.plugins,
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: 'uiw.min.css',
// allChunks: true because we want all css to be included in the main
// css bundle when doing code splitting to avoid FOUC:
// https://github.com/facebook/create-react-app/issues/2415
allChunks: true,
})
];
} else {
conf.optimization.minimize = false;
conf.plugins = [
...conf.plugins,
new MiniCssExtractPlugin({
filename: 'uiw.css',
allChunks: true,
})
];
}
}
return conf
}