-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbuild.js
More file actions
42 lines (38 loc) · 1.35 KB
/
Copy pathbuild.js
File metadata and controls
42 lines (38 loc) · 1.35 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
const esbuild = require('esbuild');
const { lessLoader } = require('esbuild-plugin-less');
const fs = require('fs');
const path = require('path');
const isDev = process.argv.includes('--dev');
const resources = ['manifest.json', 'preview.png'];
const copyFiles = (destDir) => {
resources.forEach(file => {
const srcPath = path.resolve(__dirname, 'resources', file);
const destPath = path.resolve(__dirname, destDir, file);
fs.copyFileSync(srcPath, destPath);
});
};
!(async () => {
if (isDev) {
await esbuild.build({
entryPoints: ['./src/main.tsx', './src/startup_script.ts', './src/style.less'],
bundle: true,
sourcemap: 'inline',
target: 'chrome91',
outdir: '.',
plugins: [lessLoader()],
});
copyFiles('.');
} else {
await esbuild.build({
entryPoints: ['./src/main.tsx', './src/startup_script.ts', './src/style.less'],
bundle: true,
minify: true,
outdir: 'dist',
target: 'chrome91',
plugins: [lessLoader()],
});
copyFiles('dist');
const compress = require('compressing');
await compress.zip.compressDir('./dist/', './RevivedUnblockNeteaseMusic.plugin', { ignoreBase: true });
}
})()