I'm working on a JS library with RollupJS and static files are served by an ASP.NET server. To improve my DX I want to have hot-reload.
On file changed, bundle file is rebuild with changed but no refresh happen. There is no errors in the console
I'm on a monorepo (directories):
- server (ASP.NET)
- library (JS)
rollup.config.js
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import copy from 'rollup-plugin-copy';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import pkg from './package.publish.json' assert { type: 'json' };
import html from 'rollup-plugin-html';
import css from 'rollup-plugin-import-css';
import replace from '@rollup/plugin-replace';
import livereload from 'rollup-plugin-livereload';
const outputs = [
{
file: `./dist/${pkg.exports['.'].import.default}`,
format: 'esm',
},
{
file: `./dist/${pkg.exports['.'].require.default}`,
format: 'cjs',
},
];
const config = [
{
input: 'src/index.ts',
output: [...outputs],
plugins: [
typescript(),
terser(),
replace({
preventAssignment: true,
values: {
'.css?inline': '.css',
},
}),
html(),
css(),
copy({
targets: [{
src: './package.publish.json',
dest: 'dist',
rename: () => 'package.json',
}],
}),
livereload({
watch: 'dist',
verbose: true,
delay: 600,
}),
],
},
];
export default config;
index.html (run by ASP.NET server)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
<script>window.WSPORT = '6969'</script>
<script type="module" src="library.mjs"></script>
<title>Document</title>
<script type="module">
window.setInterval(() => {
window.set('dateTime', new Date());
}, 1000)
</script>
</head>
<body>
</body>
</html>
In Program.cs I specified where to import static files
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "library", "dist", "esm")),
RequestPath = new PathString("")
});
Did I miss something in my config ?