Skip to content

Commit 440b94f

Browse files
fix: livereload & hmr
1 parent b27abab commit 440b94f

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

lib/plugins/nollup/index.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
const devServer = require('nollup/lib/dev-server')
3+
const hmr = require('rollup-plugin-hot')
34

45
module.exports.default = {
56
dependencies: { 'rollup': () => require('../rollup') },
@@ -9,18 +10,40 @@ module.exports.default = {
910
event: 'start',
1011
condition: 'development',
1112
// Nollup needs the Rollup config, so make sure Rollup compiles its config
12-
action: app => app.config.rollup.compileConfig = true
13+
14+
action: (app, params) => {
15+
app.merge({
16+
config: {
17+
rollup: { compileConfig: true },
18+
nollup: {
19+
port: params.port || app.config.roxi.port,
20+
contentBase: app.config.roxi.staticDir,
21+
hot: true,
22+
publicPath: 'build',
23+
historyApiFallback: '/__index.html',
24+
}
25+
}
26+
})
27+
}
1328
},
1429
{
1530
name: 'start nollup server',
1631
event: 'after:bundle',
1732
condition: 'development',
1833
action: async (app, params, ctx) => {
34+
const { staticDir } = app.config.roxi
35+
1936
//start the nollup dev server
2037
devServer({
2138
port: params.port || app.config.roxi.port,
2239
contentBase: app.config.roxi.staticDir,
23-
config: app.config.rollup,
40+
config: {
41+
...app.config.rollup,
42+
plugins: [
43+
...app.config.rollup.plugins.filter(plugin => plugin.name !== 'hot'),
44+
hmr({ inMemory: true, public: staticDir, compatNollup: true })
45+
]
46+
},
2447
hot: true,
2548
publicPath: 'build',
2649
historyApiFallback: '/__index.html',

lib/plugins/rollup/rollup.template.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = function rollup(app, params) {
3232
},
3333
commonjs: {},
3434
terser: production && {}, // minify
35-
livereload: !production && !isNollup && distDir,
35+
livereload: !production && buildDir,
3636
_mainJsTransform: {
3737
transform: (code, id) => {
3838
if (id.match(/[/\\]src[/\\]main.js$/)) {
@@ -45,7 +45,8 @@ module.exports = function rollup(app, params) {
4545
}
4646
},
4747

48-
hmr: production && { inMemory: true, public: staticDir }
48+
//hmr doesn't seem to have an effect outside of nollup
49+
// hmr: !production && { inMemory: true, public: staticDir, compatModuleHot: true,}
4950
},
5051
watch: {
5152
clearScreen: false,

0 commit comments

Comments
 (0)