diff --git a/build/build.js b/build/build.js index c8b9ab5..ceb5d7a 100644 --- a/build/build.js +++ b/build/build.js @@ -3,8 +3,8 @@ import { promises as fs } from 'fs'; import * as rollup from 'rollup'; import commonjs from '@rollup/plugin-commonjs'; import nodeResolve from '@rollup/plugin-node-resolve'; -import uglify from '@rollup/plugin-terser'; import replace from '@rollup/plugin-replace'; +import terser from '@rollup/plugin-terser'; import chokidar from 'chokidar'; import { relative } from './util.js'; @@ -54,6 +54,7 @@ async function build(opts) { output: opts.globalName ? { name: opts.globalName } : {}, file: dest, strict: false, + sourcemap: opts.sourcemap, }); }); } @@ -68,15 +69,14 @@ async function buildCore() { }) ); - if (isProd) { - promises.push( - build({ - input: 'src/core/index.js', - output: 'docsify.min.js', - plugins: [uglify()], - }) - ); - } + promises.push( + build({ + input: 'src/core/index.js', + output: 'docsify.min.js', + plugins: [terser()], + sourcemap: true, + }) + ); await Promise.all(promises); } @@ -102,17 +102,16 @@ async function buildAllPlugin() { }); }); - if (isProd) { - plugins.forEach(item => { - promises.push( - build({ - input: 'src/plugins/' + item.input, - output: 'plugins/' + item.name + '.min.js', - plugins: [uglify()], - }) - ); - }); - } + plugins.forEach(item => { + promises.push( + build({ + input: 'src/plugins/' + item.input, + output: 'plugins/' + item.name + '.min.js', + plugins: [terser()], + sourcemap: true, + }) + ); + }); await Promise.all(promises); } diff --git a/build/mincss.js b/build/mincss.js index 3d480c1..45c0dc1 100644 --- a/build/mincss.js +++ b/build/mincss.js @@ -9,7 +9,7 @@ const files = fs files.forEach(file => { file = path.resolve('lib/themes', file); cssnano - .process(fs.readFileSync(file)) + .process(fs.readFileSync(file), { from: file }) .then(result => { file = file.replace(/\.css$/, '.min.css'); fs.writeFileSync(file, result.css); diff --git a/server.configs.js b/server.configs.js index 2f0889c..0360bd6 100644 --- a/server.configs.js +++ b/server.configs.js @@ -24,6 +24,8 @@ export const devConfig = { files: ['CHANGELOG.md', 'docs/**/*', 'lib/**/*'], port: 3000, rewriteRules, + reloadDebounce: 1000, + reloadOnRestart: true, server: { ...prodConfig.server, routes: {