chore: 在 bundle 文件顶部添加版本号

This commit is contained in:
xream
2024-02-03 22:34:58 +08:00
parent ae1c738f70
commit 395c6e4e4a
3 changed files with 60 additions and 20 deletions

View File

@@ -4,6 +4,10 @@ const path = require('path');
const { build } = require('esbuild');
!(async () => {
const version = JSON.parse(
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8'),
).version.trim();
const artifacts = [
{ src: 'src/main.js', dest: 'sub-store.min.js' },
{
@@ -54,6 +58,16 @@ const { build } = require('esbuild');
format: 'cjs',
outfile: 'dist/sub-store.bundle.js',
});
fs.writeFileSync(
path.join(__dirname, 'dist/sub-store.bundle.js'),
`// SUB_STORE_BACKEND_VERSION: ${version}
${fs.readFileSync(path.join(__dirname, 'dist/sub-store.bundle.js'), {
encoding: 'utf8',
})}`,
{
encoding: 'utf8',
},
);
})()
.catch((e) => {
console.log(e);