mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 11:11:20 -08:00
update parcel
This commit is contained in:
1 parent
bf342975db
commit
810266c44e
7 files changed
+12
-4261
No files matched your search
+2
-1
@@ -33,13 +33,14 @@
|
|||||||
"@parcel/reporter-cli": "^2.5.0",
|
"@parcel/reporter-cli": "^2.5.0",
|
||||||
"@parcel/transformer-inline-string": "^2.5.0",
|
"@parcel/transformer-inline-string": "^2.5.0",
|
||||||
"@parcel/transformer-less": "^2.5.0",
|
"@parcel/transformer-less": "^2.5.0",
|
||||||
"cpy": "^9.0.1",
|
|
||||||
"eslint": "^8.14.0",
|
"eslint": "^8.14.0",
|
||||||
"glob": "^8.0.1",
|
"glob": "^8.0.1",
|
||||||
"inquirer": "^8.2.3",
|
"inquirer": "^8.2.3",
|
||||||
"lerna": "^4.0.0",
|
"lerna": "^4.0.0",
|
||||||
"mocha": "^9.2.2",
|
"mocha": "^9.2.2",
|
||||||
"mocha-chrome": "^2.2.0",
|
"mocha-chrome": "^2.2.0",
|
||||||
|
"node-html-parser": "^5.3.3",
|
||||||
|
"prettier": "^2.6.2",
|
||||||
"servor": "^4.0.2",
|
"servor": "^4.0.2",
|
||||||
"workbox-build": "^6.5.3"
|
"workbox-build": "^6.5.3"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-4091
File diff suppressed because it is too large.
Load diff
+9
-7
@@ -1,5 +1,4 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
|
||||||
import inquirer from 'inquirer';
|
import inquirer from 'inquirer';
|
||||||
import projects from './projects.js';
|
import projects from './projects.js';
|
||||||
import { Parcel } from '@parcel/core';
|
import { Parcel } from '@parcel/core';
|
||||||
@@ -12,12 +11,14 @@ async function develop(name) {
|
|||||||
entries: `${projects[name]}/src/index.js`,
|
entries: `${projects[name]}/src/index.js`,
|
||||||
defaultConfig: '@parcel/config-default',
|
defaultConfig: '@parcel/config-default',
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
targets: ['main'],
|
targets: {
|
||||||
defaultTargetOptions: {
|
main: {
|
||||||
sourceMaps: false,
|
distDir: `${projects[name]}/dist`,
|
||||||
outputFormat: 'global',
|
sourceMap: false,
|
||||||
engines: {
|
outputFormat: 'global',
|
||||||
browsers: ['last 1 Chrome version'],
|
engines: {
|
||||||
|
browsers: ['last 1 Chrome version'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
@@ -30,6 +31,7 @@ async function develop(name) {
|
|||||||
try {
|
try {
|
||||||
const { bundleGraph, buildTime } = await bundler.run();
|
const { bundleGraph, buildTime } = await bundler.run();
|
||||||
const bundles = bundleGraph.getBundles();
|
const bundles = bundleGraph.getBundles();
|
||||||
|
fs.renameSync(`${projects[name]}/dist/index.js`, `${projects[name]}/dist/${name}.js`);
|
||||||
console.log(`✨ Built ${bundles.length} bundles in ${buildTime}ms!`);
|
console.log(`✨ Built ${bundles.length} bundles in ${buildTime}ms!`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err.diagnostics);
|
console.log(err.diagnostics);
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
const cpy = require('cpy');
|
|
||||||
const logger = require('./logger');
|
|
||||||
|
|
||||||
module.exports = (opts = {}) => ({
|
|
||||||
name: 'copyAfterBuild',
|
|
||||||
generateBundle(outputOptions, bundle, isWrite) {
|
|
||||||
if (!isWrite) {
|
|
||||||
logger.fatal('copyAfterBuild currently only works with bundles that are written to disk');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.from && opts.to) {
|
|
||||||
setTimeout(() => {
|
|
||||||
cpy(opts.from, opts.to)
|
|
||||||
.then(() => {
|
|
||||||
logger.success(`${opts.from} successfully copied to ${opts.to}`);
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
logger.fatal('File copy failed!');
|
|
||||||
});
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const { babel } = require('@rollup/plugin-babel');
|
|
||||||
const commonjs = require('@rollup/plugin-commonjs');
|
|
||||||
const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
|
||||||
const postcss = require('rollup-plugin-postcss');
|
|
||||||
const { eslint } = require('rollup-plugin-eslint');
|
|
||||||
const autoprefixer = require('autoprefixer');
|
|
||||||
const cssnano = require('cssnano');
|
|
||||||
const replace = require('@rollup/plugin-replace');
|
|
||||||
const svgo = require('rollup-plugin-svgo');
|
|
||||||
const { terser } = require('rollup-plugin-terser');
|
|
||||||
const copyAfterBuild = require('./copyAfterBuild');
|
|
||||||
const removeHtmlSpace = require('./removeHtmlSpace');
|
|
||||||
const json = require('@rollup/plugin-json');
|
|
||||||
|
|
||||||
module.exports = function creatRollupConfig(projectPath) {
|
|
||||||
const packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));
|
|
||||||
const { version, homepage, name, expose } = packageJson;
|
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
|
||||||
const banner =
|
|
||||||
'/*!\n' +
|
|
||||||
` * ${name}.js v${version}\n` +
|
|
||||||
` * Github: ${homepage}\n` +
|
|
||||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
|
||||||
' * Released under the MIT License.\n' +
|
|
||||||
' */\n';
|
|
||||||
|
|
||||||
return {
|
|
||||||
input: path.join(projectPath, 'src/index.js'),
|
|
||||||
output: {
|
|
||||||
name: expose,
|
|
||||||
file: isProd
|
|
||||||
? path.join(projectPath, `dist/${name}.js`)
|
|
||||||
: path.join(process.cwd(), `docs/uncompiled/${name}.js`),
|
|
||||||
format: 'umd',
|
|
||||||
sourcemap: isProd ? false : true,
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
exclude: ['node_modules/**', 'packages/**/node_modules/**'],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
json({
|
|
||||||
exclude: ['node_modules/**', 'packages/**/node_modules/**'],
|
|
||||||
}),
|
|
||||||
eslint({
|
|
||||||
exclude: [
|
|
||||||
'node_modules/**',
|
|
||||||
'packages/*/src/**/*.scss',
|
|
||||||
'packages/*/src/**/*.svg',
|
|
||||||
'packages/*/src/**/*.json',
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
postcss({
|
|
||||||
plugins: [
|
|
||||||
autoprefixer(),
|
|
||||||
cssnano({
|
|
||||||
preset: [
|
|
||||||
'default',
|
|
||||||
{
|
|
||||||
calc: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
sourceMap: isProd ? false : true,
|
|
||||||
extract: false,
|
|
||||||
}),
|
|
||||||
nodeResolve(),
|
|
||||||
commonjs(),
|
|
||||||
babel({
|
|
||||||
babelHelpers: 'runtime',
|
|
||||||
exclude: ['node_modules/**', 'packages/**/node_modules/**'],
|
|
||||||
presets: [['@babel/env', { modules: false }]],
|
|
||||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
|
|
||||||
}),
|
|
||||||
svgo({
|
|
||||||
raw: true,
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
preventAssignment: true,
|
|
||||||
exclude: 'node_modules/**',
|
|
||||||
__ENV__: process.env.NODE_ENV || 'development',
|
|
||||||
__VERSION__: version,
|
|
||||||
__BUILD__: Date.now(),
|
|
||||||
}),
|
|
||||||
isProd && removeHtmlSpace(),
|
|
||||||
isProd &&
|
|
||||||
terser({
|
|
||||||
output: {
|
|
||||||
preamble: banner,
|
|
||||||
comments: function () {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
isProd &&
|
|
||||||
copyAfterBuild({
|
|
||||||
from: path.join(projectPath, 'dist/*'),
|
|
||||||
to: path.join(process.cwd(), 'dist'),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import chalk from 'chalk';
|
|
||||||
import { format } from 'util';
|
|
||||||
|
|
||||||
const prefix = 'artplayer-cli';
|
|
||||||
const sep = chalk.gray('·');
|
|
||||||
|
|
||||||
export function log(...args) {
|
|
||||||
const msg = format.apply(format, args);
|
|
||||||
console.log(chalk.white(prefix), sep, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fatal(...args) {
|
|
||||||
if (args[0] instanceof Error) args[0] = args[0].message.trim();
|
|
||||||
const msg = format.apply(format, args);
|
|
||||||
console.error(chalk.red(prefix), sep, msg);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function success(...args) {
|
|
||||||
const msg = format.apply(format, args);
|
|
||||||
console.log(chalk.green(prefix), sep, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function warn(...args) {
|
|
||||||
const msg = format.apply(format, args);
|
|
||||||
console.log(chalk.yellow(prefix), sep, msg);
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
module.exports = () => ({
|
|
||||||
name: 'removeHtmlSpace',
|
|
||||||
transform(code) {
|
|
||||||
return {
|
|
||||||
code: code.replace(/\\n*\s*</g, '<').replace(/>\\n*\s*/g, '>'),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Reference in new issue
Block a user