Skip to content

Commit

Permalink
Fix dev hot reload and add sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed Apr 10, 2024
1 parent 87fd55d commit 7ce9c83
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
41 changes: 20 additions & 21 deletions build/build.js
Expand Up @@ -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';

Expand Down Expand Up @@ -54,6 +54,7 @@ async function build(opts) {
output: opts.globalName ? { name: opts.globalName } : {},
file: dest,
strict: false,
sourcemap: opts.sourcemap,
});
});
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions server.configs.js
Expand Up @@ -24,6 +24,8 @@ export const devConfig = {
files: ['CHANGELOG.md', 'docs/**/*', 'lib/**/*'],
port: 3000,
rewriteRules,
reloadDebounce: 1000,
reloadOnRestart: true,
server: {
...prodConfig.server,
routes: {
Expand Down

0 comments on commit 7ce9c83

Please sign in to comment.