-
-
Save tedpatrick/d0ab5155e2738d2b7c61d013b11a4f0e to your computer and use it in GitHub Desktop.
PyScript rollup config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commonjs from "@rollup/plugin-commonjs"; | |
import resolve from "@rollup/plugin-node-resolve"; | |
import { terser } from "rollup-plugin-terser"; | |
import legacy from '@rollup/plugin-legacy'; | |
import typescript from "@rollup/plugin-typescript"; | |
import css from "rollup-plugin-css-only"; | |
import serve from "rollup-plugin-serve"; | |
import { string } from "rollup-plugin-string"; | |
import copy from 'rollup-plugin-copy' | |
const production = (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: [ | |
{ | |
sourcemap: true, | |
format: "iife", | |
inlineDynamicImports: true, | |
name: "app", | |
file: "build/pyscript.js", | |
}, | |
{ | |
file: "build/pyscript.min.js", | |
format: "iife", | |
sourcemap: true, | |
inlineDynamicImports: true, | |
plugins: [terser()], | |
}, | |
], | |
plugins: [ | |
css({ output: "pyscript.css" }), | |
// Bundle all the Python files into the output file | |
string({ | |
include: "./src/**/*.py", | |
}), | |
legacy({ 'src/toml.js': 'toml' }), | |
resolve({ | |
browser: true, | |
dedupe: ["svelte"], | |
}), | |
commonjs(), | |
typescript({ | |
sourceMap: !production, | |
inlineSources: !production, | |
}), | |
// copy directory listing + build to examples if !production | |
copy(copy_targets), | |
!production && serve({ | |
port: 8080, | |
contentBase: 'examples' | |
}) | |
], | |
watch: { | |
clearScreen: false, | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment