1
|
-const { merge } = require('webpack-merge');
|
|
|
2
|
-const prodConfig = require('./webpack.prod');
|
1
|
+const CopyPlugin = require("copy-webpack-plugin");
|
|
|
2
|
+const { merge } = require("webpack-merge");
|
|
|
3
|
+const prodConfig = require("./webpack.prod");
|
3
|
const WebpackBar = require("webpackbar");
|
4
|
const WebpackBar = require("webpackbar");
|
4
|
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
5
|
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
5
|
-const path = require('path')
|
|
|
6
|
-const { cwd } = require('process')
|
6
|
+const path = require("path");
|
|
|
7
|
+const fs = require("fs");
|
|
|
8
|
+const { cwd } = require("process");
|
7
|
|
9
|
|
8
|
-delete prodConfig.plugins
|
10
|
+delete prodConfig.plugins;
|
|
|
11
|
+
|
|
|
12
|
+const extensions = ["ts", "tsx"];
|
|
|
13
|
+
|
|
|
14
|
+let extension;
|
|
|
15
|
+
|
|
|
16
|
+extensions.forEach((i) => {
|
|
|
17
|
+ if (fs.existsSync(path.resolve(cwd(), `index.${i}`))) {
|
|
|
18
|
+ extension = i;
|
|
|
19
|
+ }
|
|
|
20
|
+});
|
|
|
21
|
+
|
|
|
22
|
+const name = cwd().split("/").reverse()[0];
|
9
|
|
23
|
|
10
|
module.exports = merge(prodConfig, {
|
24
|
module.exports = merge(prodConfig, {
|
11
|
output: {
|
25
|
output: {
|
12
|
- filename: 'index.js',
|
|
|
13
|
- libraryTarget: 'system',
|
26
|
+ filename: `../../../dist/${name}/index.js`,
|
|
|
27
|
+ libraryTarget: "system",
|
14
|
},
|
28
|
},
|
15
|
- entry: path.resolve(cwd(), './index.ts'),
|
29
|
+ entry: path.resolve(cwd(), `./index.${extension}`),
|
16
|
plugins: [
|
30
|
plugins: [
|
|
|
31
|
+ new CopyPlugin({
|
|
|
32
|
+ patterns: [
|
|
|
33
|
+ {
|
|
|
34
|
+ from: path.resolve(cwd(), '../../plugin.json'),
|
|
|
35
|
+ to: path.resolve(cwd(), '../../dist/plugin.json'),
|
|
|
36
|
+ },
|
|
|
37
|
+ ],
|
|
|
38
|
+ }),
|
|
|
39
|
+ new CopyPlugin({
|
|
|
40
|
+ patterns: [
|
|
|
41
|
+ {
|
|
|
42
|
+ from: path.resolve(cwd(), '../../static'),
|
|
|
43
|
+ to: path.resolve(cwd(), '../../dist/static'),
|
|
|
44
|
+ },
|
|
|
45
|
+ ],
|
|
|
46
|
+ }),
|
17
|
new WebpackBar(),
|
47
|
new WebpackBar(),
|
18
|
- new NodePolyfillPlugin()
|
48
|
+ new NodePolyfillPlugin(),
|
19
|
],
|
49
|
],
|
20
|
}); |
50
|
}); |