mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-14 08:26:16 -08:00
update
This commit is contained in:
1 parent
3fc4b99841
commit
bf342975db
9 files changed
+9215
-86
No files matched your search
+46
-63
@@ -1,67 +1,50 @@
|
||||
const path = require('path');
|
||||
const inquirer = require('inquirer');
|
||||
const rollup = require('rollup');
|
||||
const del = require('del');
|
||||
const logger = require('./logger');
|
||||
const projects = require('./getProjects')();
|
||||
const creatRollupConfig = require('./creatRollupConfig');
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import inquirer from 'inquirer';
|
||||
import projects from './projects.js';
|
||||
import { Parcel } from '@parcel/core';
|
||||
|
||||
const isBuildAll = process.argv.pop() === 'all';
|
||||
async function develop(name) {
|
||||
const { version } = JSON.parse(fs.readFileSync(`${projects[name]}/package.json`, 'utf-8'));
|
||||
process.chdir(projects[name]);
|
||||
|
||||
function runPromisesInSeries(ps) {
|
||||
return ps.reduce((p, next) => p.then(next), Promise.resolve());
|
||||
}
|
||||
|
||||
function build(projectPath) {
|
||||
const { input, output, plugins } = creatRollupConfig(projectPath);
|
||||
const dist = path.join(projectPath, 'dist');
|
||||
return del(dist).then(() => {
|
||||
logger.success(`----Delete directory successfully: ${dist}----`);
|
||||
logger.log(`bundling ${output.file}...`);
|
||||
return rollup
|
||||
.rollup({
|
||||
input,
|
||||
plugins,
|
||||
})
|
||||
.then((bundle) => {
|
||||
bundle.write(output);
|
||||
logger.success(`finished building all bundles from ${projectPath}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (isBuildAll) {
|
||||
const bundles = [];
|
||||
Object.keys(projects).forEach((item) => {
|
||||
const projectPath = projects[item];
|
||||
bundles.push(() => build(projectPath));
|
||||
});
|
||||
|
||||
const dist = path.join(process.cwd(), 'dist');
|
||||
del(dist).then(() => {
|
||||
logger.success(`----Delete directory successfully: ${dist}----`);
|
||||
runPromisesInSeries(bundles)
|
||||
.then(() => {
|
||||
logger.success('----finished building all packages----');
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.fatal(err);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
message: 'Which project do you want to build?',
|
||||
name: 'project',
|
||||
choices: Object.keys(projects),
|
||||
const bundler = new Parcel({
|
||||
entries: `${projects[name]}/src/index.js`,
|
||||
defaultConfig: '@parcel/config-default',
|
||||
mode: 'production',
|
||||
targets: ['main'],
|
||||
defaultTargetOptions: {
|
||||
sourceMaps: false,
|
||||
outputFormat: 'global',
|
||||
engines: {
|
||||
browsers: ['last 1 Chrome version'],
|
||||
},
|
||||
])
|
||||
.then((answers) => {
|
||||
build(projects[answers.project]);
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.fatal(err);
|
||||
});
|
||||
},
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
APP_VER: version,
|
||||
BUILD_DATE: Date.now(),
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const { bundleGraph, buildTime } = await bundler.run();
|
||||
const bundles = bundleGraph.getBundles();
|
||||
console.log(`✨ Built ${bundles.length} bundles in ${buildTime}ms!`);
|
||||
} catch (err) {
|
||||
console.log(err.diagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
message: 'Which project do you want to build?',
|
||||
name: 'project',
|
||||
choices: Object.keys(projects),
|
||||
},
|
||||
])
|
||||
.then((answers) => {
|
||||
develop(answers.project);
|
||||
});
|
||||
+19
-9
@@ -1,11 +1,16 @@
|
||||
import inquirer from 'inquirer';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import servor from 'servor';
|
||||
import projects from './projects.js';
|
||||
import openBrowser from 'servor/utils/openBrowser.js';
|
||||
import { Parcel } from '@parcel/core';
|
||||
import inquirer from 'inquirer';
|
||||
import { fileURLToPath } from 'url';
|
||||
import projects from './projects.js';
|
||||
import { Parcel } from '@parcel/core';
|
||||
import openBrowser from 'servor/utils/openBrowser.js';
|
||||
|
||||
async function develop(name) {
|
||||
const uncompiledPath = path.resolve(`docs/uncompiled/${name}`);
|
||||
const { version } = JSON.parse(fs.readFileSync(`${projects[name]}/package.json`, 'utf-8'));
|
||||
|
||||
const { url } = await servor({
|
||||
root: 'docs',
|
||||
fallback: 'index.html',
|
||||
@@ -14,20 +19,25 @@ async function develop(name) {
|
||||
});
|
||||
|
||||
openBrowser(url);
|
||||
process.chdir(projects[name]);
|
||||
|
||||
const bundler = new Parcel({
|
||||
entries: `${projects[name]}/src/index.js`,
|
||||
defaultConfig: '@parcel/config-default',
|
||||
mode: 'development',
|
||||
targets: ['modern'],
|
||||
defaultTargetOptions: {
|
||||
distDir: `docs/uncompiled`,
|
||||
engines: {
|
||||
browsers: ['last 1 Chrome version'],
|
||||
targets: {
|
||||
main: {
|
||||
distDir: uncompiledPath,
|
||||
outputFormat: 'global',
|
||||
engines: {
|
||||
browsers: ['last 1 Chrome version'],
|
||||
},
|
||||
},
|
||||
},
|
||||
env: {
|
||||
NODE_ENV: 'development',
|
||||
APP_VER: version,
|
||||
BUILD_DATE: Date.now(),
|
||||
},
|
||||
additionalReporters: [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user