-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathwebpack.config.js
More file actions
63 lines (56 loc) · 1.33 KB
/
Copy pathwebpack.config.js
File metadata and controls
63 lines (56 loc) · 1.33 KB
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
import path, {dirname} from 'node:path';
import {fileURLToPath} from 'node:url';
import TerserPlugin from 'terser-webpack-plugin';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const dir = './lib';
const dist = path.resolve(__dirname, 'dist');
const devtool = 'source-map';
const rules = [{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
'clean-css-loader',
],
}, {
test: /\.(png|gif|svg|woff|woff2|eot|ttf)$/,
use: [{
loader: 'url-loader',
options: {
limit: Infinity,
},
}],
}];
const optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: true,
}),
],
};
const filename = `[name].min.js`;
export default {
devtool,
entry: {
'smalltalk': `${dir}/smalltalk.js`,
'smalltalk.native': `${dir}/smalltalk.native.js`,
},
optimization,
output: {
library: 'smalltalk',
filename,
path: dist,
pathinfo: true,
libraryTarget: 'var',
devtoolModuleFilenameTemplate,
},
module: {
rules,
},
};
function devtoolModuleFilenameTemplate(info) {
const resource = info.absoluteResourcePath.replace(__dirname + path.sep, '');
return `file://smalltalk/${resource}`;
}