mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
38d6a515e2
* updated PyPi version to 2.7.0a101 * updated PyPi version to 2.7.0a102 * updated PyPi version to 2.8.0b * uncache output audio * updated PyPi version to 2.8.0b2 * fix global css path * updated PyPi version to 2.8.0b3 Co-authored-by: Ali Abid <aliabid94@gmail.com>
122 lines
3.0 KiB
JavaScript
122 lines
3.0 KiB
JavaScript
import svelte from 'rollup-plugin-svelte';
|
|
import sveltePreprocess from "svelte-preprocess";
|
|
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 css from 'rollup-plugin-css-only';
|
|
import replace from '@rollup/plugin-replace';
|
|
import json from "@rollup/plugin-json";
|
|
import copy from 'rollup-plugin-copy';
|
|
import postcss from 'rollup-plugin-postcss';
|
|
var fs = require("fs");
|
|
|
|
const production = !process.env.ROLLUP_WATCH;
|
|
const PIP_VERSION = fs.readFileSync("../gradio/version.txt")
|
|
|
|
function serve() {
|
|
let server;
|
|
|
|
function toExit() {
|
|
if (server) server.kill(0);
|
|
}
|
|
|
|
return {
|
|
writeBundle() {
|
|
if (server) return;
|
|
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
|
stdio: ['ignore', 'inherit', 'inherit'],
|
|
shell: true
|
|
});
|
|
|
|
process.on('SIGTERM', toExit);
|
|
process.on('exit', toExit);
|
|
}
|
|
};
|
|
}
|
|
|
|
export default {
|
|
input: 'src/main.js',
|
|
output: [{
|
|
sourcemap: true,
|
|
format: 'iife',
|
|
name: 'app',
|
|
file: 'public/build/bundle.js'
|
|
}, {
|
|
sourcemap: true,
|
|
format: 'iife',
|
|
name: 'app',
|
|
file: '../gradio/templates/frontend/build/bundle.js'
|
|
}],
|
|
plugins: [
|
|
copy({
|
|
targets: [
|
|
{ src: 'public/*', dest: '../gradio/templates/frontend' },
|
|
{ src: 'public/global.css', dest: '../gradio/templates/frontend/build' },
|
|
{ src: 'public/static', dest: '../gradio/templates/frontend' }
|
|
]
|
|
}),
|
|
json(),
|
|
replace({
|
|
BUILD_MODE: production ? "prod" : "dev",
|
|
BACKEND_URL: production ? "" : "http://localhost:7860/",
|
|
PIP_VERSION: PIP_VERSION
|
|
}),
|
|
postcss({
|
|
extract: 'themes.css',
|
|
plugins: [
|
|
require("tailwindcss"),
|
|
require("postcss-nested"),
|
|
require("autoprefixer"),
|
|
]
|
|
}),
|
|
svelte({
|
|
preprocess: sveltePreprocess({
|
|
// sourceMap: true,
|
|
postcss: {
|
|
plugins: [
|
|
require("tailwindcss"),
|
|
require("postcss-nested"),
|
|
require("autoprefixer"),
|
|
],
|
|
},
|
|
}),
|
|
compilerOptions: {
|
|
// enable run-time checks when not in production
|
|
dev: !production
|
|
}
|
|
}),
|
|
// we'll extract any component CSS out into
|
|
// a separate file - better for performance
|
|
css({
|
|
output: 'bundle.css'
|
|
}),
|
|
|
|
// If you have external dependencies installed from
|
|
// npm, you'll most likely need these plugins. In
|
|
// some cases you'll need additional configuration -
|
|
// consult the documentation for details:
|
|
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
|
resolve({
|
|
browser: true,
|
|
dedupe: ['svelte']
|
|
}),
|
|
commonjs(),
|
|
|
|
// In dev mode, call `npm run start` once
|
|
// the bundle has been generated
|
|
!production && serve(),
|
|
|
|
// Watch the `public` directory and refresh the
|
|
// browser on changes when not in production
|
|
!production && livereload('public'),
|
|
|
|
// If we're building for production (npm run build
|
|
// instead of npm run dev), minify
|
|
production && terser()
|
|
],
|
|
watch: {
|
|
clearScreen: false
|
|
}
|
|
};
|