forked from ozntel/file-tree-alternative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
34 lines (31 loc) · 960 Bytes
/
esbuild.config.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
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
If you want to view the source, visit the plugins github repository
https://github.com/ozntel/file-tree-alternative
*/
`;
const isProd = process.env.BUILD === 'production';
const fs = require('fs');
let renamePlugin = {
name: 'rename-styles',
setup(build) {
build.onEnd(() => {
const { outfile } = build.initialOptions;
const outcss = outfile.replace(/\.js$/, '.css');
const fixcss = outfile.replace(/main\.js$/, 'styles.css');
if (fs.existsSync(outcss)) {
console.log('Renaming', outcss, 'to', fixcss);
fs.renameSync(outcss, fixcss);
}
});
},
};
module.exports = {
banner: { js: banner },
sourcemap: isProd ? false : 'inline',
minify: true,
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.BUILD),
},
plugins: [renamePlugin],
};