mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-29 18:48:14 +08:00
fix: dev mode hot reload and add sourcemaps (#2402)
--------- Co-authored-by: Koy Zhuang <koy@ko8e24.top> Co-authored-by: sy-records <52o@qq52o.cn>
This commit is contained in:
parent
a3ab2be0b0
commit
947d8decb8
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -24,6 +24,8 @@ export const devConfig = {
|
||||
files: ['CHANGELOG.md', 'docs/**/*', 'lib/**/*'],
|
||||
port: 3000,
|
||||
rewriteRules,
|
||||
reloadDebounce: 1000,
|
||||
reloadOnRestart: true,
|
||||
server: {
|
||||
...prodConfig.server,
|
||||
routes: {
|
||||
|
Loading…
Reference in New Issue
Block a user