Skip to content

Commit

Permalink
feat: realtime sync of public > dist
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Aug 31, 2020
1 parent a8f15f7 commit 5164adb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/bundlers/rollup/configs/base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import resolve from '@rollup/plugin-node-resolve'
import { spassr } from 'spassr'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import copy from 'rollup-plugin-copy'
import copy from 'rollup-plugin-copy-watch'
import Hmr from 'rollup-plugin-hot'
import livereload from 'rollup-plugin-livereload'
import { readFileSync } from 'fs'
Expand Down Expand Up @@ -39,7 +39,8 @@ export default function (options) {
: { format: 'iife', file: `${buildDir}/bundle.js` }
},
plugins: [
useDynamicImports && copy({
counter('copyToDist', 1) && copy({
watch: 'public',
targets: [
{ src: [`${staticDir}/*`, "!*/(__index.html)"], dest: distDir },
{ src: [`${staticDir}/__index.html`], dest: distDir, rename: '__app.html', transform },
Expand Down Expand Up @@ -102,3 +103,12 @@ export default function (options) {
}
}
}


function counter(id, max) {
counter['ids'] = counter['ids'] || {}
const ids = counter['ids']
ids[id] = ids[id] || 0
ids[id]++
return ids[id] <= max
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"npm": "^6.14.5",
"ora": "^4.0.4",
"rollup": "^2.17.0",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-copy-watch": "^0.0.1",
"rollup-plugin-hot": "0.0.31",
"rollup-plugin-livereload": "^1.3.0",
"rollup-plugin-svelte-hot": "^0.9.2",
Expand Down

0 comments on commit 5164adb

Please sign in to comment.