forked from lutzroeder/netron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
64 lines (61 loc) · 1.96 KB
/
webpack.prod.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
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const less = require('less');
const fs = require('fs');
// const topLevelDeps = ['dagre', 'base', 'index', 'text', 'json', 'python', 'protobuf',
// 'flatbuffers', 'zip', 'gzip', 'tar', 'view-grapher', 'view-sidebar', 'view', 'index'];
module.exports = {
mode: 'production',
entry: {
index: [path.resolve(__dirname, `/build/index`)],
modelFactory: [path.resolve(__dirname, `/build/modelFactory`)]
},
resolve: {
// Add ".ts" and ".tsx" as resolvable extensions.
extensions: ['.js', '.json', 'css'],
fallback: { "zlib": false }
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
loader: './wrapperLoader',
exclude: /node_modules/
}
]
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{
from: 'build/css/index.less',
to: './[name].css',
transform() {
const src = 'build/css/index.less';
// 调用less.render()将Less代码编译为css代码
return less.render(fs.readFileSync(src).toString(), {
filename: path.resolve(src), // <- here we go
}).then(output => {
return output.css;
});
}
}
]
})
],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'lib'),
globalObject: 'this',
libraryTarget: 'umd',
library: '[name]',
publicPath: './'
}
};