Use only single rollup-plugin-copy() to avoid race condition (#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>
This commit is contained in:
Jeff Glass
2022-10-12 12:05:14 -05:00
committed by GitHub
parent 6c8afb05a7
commit b184c92f01

View File

@@ -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";
@@ -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",
@@ -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,