chore: update scripts.

pull/465/head
jaywcjlove 1 year ago
parent 2767829cc7
commit aeaff2d5dd

@ -2,16 +2,24 @@ import path from 'path';
import webpack from 'webpack';
import lessModules from '@kkt/less-modules';
import rawModules from '@kkt/raw-modules';
import { disableScopePlugin } from '@kkt/scope-plugin-options';
import scopePluginOptions from '@kkt/scope-plugin-options';
import pkg from './package.json';
export default (conf, env, options) => {
conf = lessModules(conf, env, options);
conf = rawModules(conf, env, options);
conf = disableScopePlugin(conf);
conf = scopePluginOptions(conf, env, {
...options,
allowedFiles: [path.resolve(process.cwd(), 'README.md')],
allowedFiles: [
path.resolve(process.cwd(), 'README.md'),
path.resolve(process.cwd(), 'src')
],
});
conf.ignoreWarnings = [
{ module: /node_modules[\\/]parse5[\\/]/ }
];
// Get the project version.
conf.plugins.push(
new webpack.DefinePlugin({

20558
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -8,9 +8,9 @@
"scripts": {
"prepare": "npm run build:lib && husky install",
"lint": "eslint --ignore-pattern dist --ext .js src website",
"build:lib": "node scripts/build.js",
"build:lib": "node scripts/build.mjs",
"build": "npm run build:lib && npm run doc && npm run lint",
"watch": "node scripts/watch.js",
"watch": "node scripts/watch.mjs",
"pretest": "npm run build",
"test": "jest --coverage --detectOpenHandles",
"test:watch": "jest --watch",
@ -46,18 +46,19 @@
},
"devDependencies": {
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@kkt/less-modules": "^7.5.2",
"@kkt/raw-modules": "^7.5.2",
"@kkt/scope-plugin-options": "^7.5.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@uiw/react-github-corners": "^1.5.15",
"@uiw/react-mac-keyboard": "^1.1.5",
"@uiw/react-markdown-preview": "^4.1.13",
"@uiw/react-shields": "^1.1.3",
"@uiw/react-markdown-preview": "^5.0.3",
"@uiw/react-shields": "^2.0.1",
"@wcj/dark-mode": "~1.0.15",
"bannerjs": "~2.1.0",
"bannerjs": "^3.0.2",
"classnames": "^2.3.2",
"colors-cli": "^1.0.32",
"eslint": "^8.44.0",
@ -66,14 +67,14 @@
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"husky": "^8.0.3",
"jest": "~27.5.1",
"jest": "^29.7.0",
"kkt": "^7.5.2",
"lint-staged": "^13.2.3",
"lint-staged": "^15.2.0",
"puppeteer": "~13.5.2",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"rimraf": "^5.0.1",
"rollup": "^3.26.2",
"rollup": "^4.7.0",
"uglify-js": "^3.17.4"
},
"browserslist": {

@ -1,22 +1,21 @@
const fs = require('fs');
const path = require('path');
const rollup = require('rollup');
const babel = require('@rollup/plugin-babel');
const nodeResolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const banner = require('bannerjs');
const zlib = require('zlib');
// const pkg = require('../package.json');
const uglify = require('uglify-js');
require('colors-cli/toxic');
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import path from 'path';
import fs from 'fs';
import zlib from 'zlib';
import { rollup } from 'rollup';
import { multibanner, onebanner } from 'bannerjs';
import { babel } from '@rollup/plugin-babel';
import uglify from 'uglify-js';
import 'colors-cli/toxic';
// see below for details on the options
const inputOptions = {
input: 'src/index.js',
plugins: [
nodeResolve.default(), // so Rollup can find `ms`
nodeResolve(), // so Rollup can find `ms`
commonjs(), // so Rollup can convert `ms` to an ES module
babel.default({
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**', // 只编译我们的源代码
presets: [[
@ -34,7 +33,7 @@ const inputOptions = {
async function build() {
// create a bundle
const bundle = await rollup.rollup(inputOptions);
const bundle = await rollup(inputOptions);
const uglifyOption = {
compress: {
@ -54,23 +53,23 @@ async function build() {
const umd = await bundle.generate({
format: 'umd',
name: 'hotkeys',
banner: banner.multibanner(),
banner: multibanner(),
});
const umdMinified = `${banner.onebanner()}\n${uglify.minify(umd.output[0].code, uglifyOption).code}`;
const umdMinified = `${onebanner()}\n${uglify.minify(umd.output[0].code, uglifyOption).code}`;
const common = await bundle.generate({
format: 'cjs',
name: 'hotkeys',
exports: 'auto',
banner: banner.multibanner(),
banner: multibanner(),
});
const commonMinified = `${banner.onebanner()}\n${uglify.minify(common.output[0].code, uglifyOption).code}`;
const commonMinified = `${onebanner()}\n${uglify.minify(common.output[0].code, uglifyOption).code}`;
const es = await bundle.generate({
format: 'es',
name: 'hotkeys',
banner: banner.multibanner(),
banner: multibanner(),
});
write('dist/hotkeys.js', umd.output[0].code)

@ -1,17 +1,18 @@
const path = require('path');
const rollup = require('rollup');
const babel = require('@rollup/plugin-babel');
const nodeResolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const banner = require('bannerjs');
require('colors-cli/toxic');
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import path from 'path';
import { watch } from 'rollup';
import { multibanner } from 'bannerjs';
import { babel } from '@rollup/plugin-babel';
import 'colors-cli/toxic';
const watchOptions = {
input: 'src/index.js',
plugins: [
nodeResolve.default(), // so Rollup can find `ms`
nodeResolve(), // so Rollup can find `ms`
commonjs(), // so Rollup can convert `ms` to an ES module
babel.default({
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**', // 只编译我们的源代码
presets: [[
@ -30,24 +31,24 @@ const watchOptions = {
file: 'dist/hotkeys.common.js',
name: 'hotkeys',
exports: 'auto',
banner: banner.multibanner(),
banner: multibanner(),
format: 'cjs',
},
{
file: 'dist/hotkeys.js',
name: 'hotkeys',
banner: banner.multibanner(),
banner: multibanner(),
format: 'umd',
},
{
file: 'dist/hotkeys.esm.js',
name: 'hotkeys',
banner: banner.multibanner(),
banner: multibanner(),
format: 'es',
},
],
};
const watcher = rollup.watch(watchOptions);
const watcher = watch(watchOptions);
watcher.on('event', (event) => {
if (event.code === 'FATAL') {
Loading…
Cancel
Save