|
@ -5,13 +5,13 @@ import livereload from 'rollup-plugin-livereload'; |
|
|
import { terser } from 'rollup-plugin-terser'; |
|
|
import { terser } from 'rollup-plugin-terser'; |
|
|
import sveltePreprocess from 'svelte-preprocess'; |
|
|
import sveltePreprocess from 'svelte-preprocess'; |
|
|
import typescript from '@rollup/plugin-typescript'; |
|
|
import typescript from '@rollup/plugin-typescript'; |
|
|
|
|
|
import replace from '@rollup/plugin-replace' |
|
|
|
|
|
|
|
|
const production = !process.env.ROLLUP_WATCH; |
|
|
const production = !process.env.ROLLUP_WATCH; |
|
|
const halfProduction = production || !!process.env.HALF_PRODUCTION; |
|
|
const halfProduction = production || !!process.env.HALF_PRODUCTION; |
|
|
|
|
|
|
|
|
function serve() { |
|
|
function serve() { |
|
|
let server; |
|
|
let server; |
|
|
|
|
|
|
|
|
function toExit() { |
|
|
function toExit() { |
|
|
if (server) server.kill(0); |
|
|
if (server) server.kill(0); |
|
|
} |
|
|
} |
|
@ -30,33 +30,19 @@ function serve() { |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default { |
|
|
function plugins(editor) { |
|
|
input: 'src/main.ts', |
|
|
return [ |
|
|
output: { |
|
|
|
|
|
sourcemap: true, |
|
|
|
|
|
format: 'es', |
|
|
|
|
|
name: 'app', |
|
|
|
|
|
file: 'public/build/bundle.js' |
|
|
|
|
|
}, |
|
|
|
|
|
plugins: [ |
|
|
|
|
|
// nodePolyfills(),
|
|
|
|
|
|
|
|
|
|
|
|
svelte({ |
|
|
svelte({ |
|
|
// enable run-time checks when not in production
|
|
|
// enable run-time checks when not in production
|
|
|
dev: !halfProduction, |
|
|
dev: !halfProduction, |
|
|
// we'll extract any component CSS out into
|
|
|
// we'll extract any component CSS out into
|
|
|
// a separate file - better for performance
|
|
|
// a separate file - better for performance
|
|
|
css: css => { |
|
|
css: css => { |
|
|
css.write('bundle.css'); |
|
|
css.write(editor ? 'editor.css' : 'bundle.css'); |
|
|
}, |
|
|
}, |
|
|
preprocess: sveltePreprocess(), |
|
|
preprocess: sveltePreprocess(), |
|
|
}), |
|
|
}), |
|
|
|
|
|
|
|
|
// 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({ |
|
|
resolve({ |
|
|
browser: true, |
|
|
browser: true, |
|
|
dedupe: ['svelte'] |
|
|
dedupe: ['svelte'] |
|
@ -66,20 +52,42 @@ export default { |
|
|
sourceMap: !halfProduction, |
|
|
sourceMap: !halfProduction, |
|
|
inlineSources: !halfProduction |
|
|
inlineSources: !halfProduction |
|
|
}), |
|
|
}), |
|
|
|
|
|
replace({ |
|
|
|
|
|
"allowEditor": false, |
|
|
|
|
|
}), |
|
|
|
|
|
|
|
|
// In dev mode, call `npm run start` once
|
|
|
// In dev mode, call `npm run start` once
|
|
|
// the bundle has been generated
|
|
|
// the bundle has been generated
|
|
|
!production && serve(), |
|
|
!production && !editor && serve(), |
|
|
|
|
|
|
|
|
// Watch the `public` directory and refresh the
|
|
|
// Watch the `public` directory and refresh the
|
|
|
// browser on changes when not in production
|
|
|
// browser on changes when not in production
|
|
|
!halfProduction && livereload('public'), |
|
|
!halfProduction && !editor && livereload('public'), |
|
|
|
|
|
|
|
|
// If we're building for production (npm run build
|
|
|
// If we're building for production (npm run build
|
|
|
// instead of npm run dev), minify
|
|
|
// instead of npm run dev), minify
|
|
|
halfProduction && terser() |
|
|
// halfProduction && terser()
|
|
|
], |
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default [{ |
|
|
|
|
|
input: 'src/main.ts', |
|
|
|
|
|
output: { |
|
|
|
|
|
sourcemap: !halfProduction, |
|
|
|
|
|
format: 'es', |
|
|
|
|
|
file: 'public/build/bundle.js' |
|
|
|
|
|
}, |
|
|
|
|
|
plugins: plugins(false), |
|
|
watch: { |
|
|
watch: { |
|
|
clearScreen: false |
|
|
clearScreen: false |
|
|
} |
|
|
} |
|
|
}; |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
input: 'src/editor-main.ts', |
|
|
|
|
|
output: { |
|
|
|
|
|
sourcemap: !halfProduction, |
|
|
|
|
|
format: 'es', |
|
|
|
|
|
file: 'public/build/editor.js' |
|
|
|
|
|
}, |
|
|
|
|
|
plugins: plugins(true) |
|
|
|
|
|
}]; |
|
|