| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const path = require('path');
- const shell = require('shelljs');
- const work_dir = path.join(__dirname, '..');
- function build() {
- shell.cd(work_dir);
- shell.rm('-rf', 'dist');
- shell.exec('npx vite build');
- shell.cd('dist');
- shell.mkdir('src');
- shell.cp('-R', '../src/assets', './src/');
- shell.cd(work_dir);
- }
- function pack() {
- const file_name = genFileName();
- const folder_name = `dist_${file_name}`;
- const zip_name = `${folder_name}.zip`
- const release_dir = '~/Desktop/';
- shell.cp('-R', './dist', folder_name);
- shell.exec(`zip -q -r ${zip_name} ${folder_name}`);
- shell.rm('-rf', folder_name);
- shell.mv(zip_name, release_dir);
- '-'.repeat(32).split('').forEach((item, index, val) => {
- if (index <= 3) console.log(val.join(''));
- });
- console.log(`Target File Path:${release_dir}${zip_name}`);
- }
- function genFileName() {
- const dt = new Date();
- const str_full = dt.toISOString();
- const str_1 = str_full.replace('T', '_');
- const str_2 = str_1.replace(/:/g, '-');
- const str_3 = str_2.replace(/.[0-9]{3}Z/, '');
- return str_3;
- }
- (function autorun() {build();pack();})();
|