Skip to content

Commit

Permalink
Use only single rollup-plugin-copy() to avoid race condition (pyscrip…
Browse files Browse the repository at this point in the history
…t#843)

* Use only single copy() plugin to avoid race condition

* clean production def, better copy_target structure

* Restore '!process.env.ROLLUP_WATCH to production definition

Co-authored-by: Ted Patrick <tpatrick@anaconda.com>
  • Loading branch information
JeffersGlass and Ted Patrick committed Oct 17, 2022
1 parent 7b9f9cc commit fe105ef
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions pyscriptjs/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser";
import legacy from '@rollup/plugin-legacy';
import typescript from "@rollup/plugin-typescript";
Expand All @@ -11,15 +10,25 @@ import copy from 'rollup-plugin-copy'

const production = !process.env.ROLLUP_WATCH || (process.env.NODE_ENV === "production");

const copy_targets = {
targets: [
{ src: 'public/index.html', dest: 'build' }
]
}

if( !production ){
copy_targets.targets.push({ src: 'build/*', dest: 'examples/build' })
}

export default {
input: "src/main.ts",
output: [
output:[
{
sourcemap: true,
format: "iife",
inlineDynamicImports: true,
name: "app",
file: "build/pyscript.js",
sourcemap: true,
format: "iife",
inlineDynamicImports: true,
name: "app",
file: "build/pyscript.js",
},
{
file: "build/pyscript.min.js",
Expand All @@ -46,23 +55,12 @@ export default {
inlineSources: !production,
}),
// This will make sure that examples will always get the latest build folder
!production && copy({
targets: [
{ src: 'build/*', dest: 'examples/build' },
]
}),
copy({
targets: [
{ src: 'public/index.html', dest: 'build' },
]
}),
!production && serve(),
!production && livereload("public"),
copy(copy_targets),
// production && terser(),
!production && serve({
port: 8080,
contentBase: 'examples'
})
contentBase: 'examples'}
)
],
watch: {
clearScreen: false,
Expand Down

0 comments on commit fe105ef

Please sign in to comment.