update svelte
This commit is contained in:
parent
e54e194325
commit
06fd9594ad
3 changed files with 1588 additions and 342 deletions
|
@ -15,10 +15,10 @@
|
|||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"rollup": "^2.26.7",
|
||||
"rollup-plugin-livereload": "^2.0.0",
|
||||
"rollup-plugin-serve": "^1.0.4",
|
||||
"rollup-plugin-svelte": "^6.0.0",
|
||||
"rollup-plugin-svelte-static-html": "^0.1.0",
|
||||
"rollup-plugin-terser": "^7.0.1",
|
||||
"sirv-cli": "^1.0.6",
|
||||
"svelte": "^3.24.1",
|
||||
"tosource": "^2.0.0-alpha.2",
|
||||
"uglify-js": "^3.10.2"
|
||||
|
|
|
@ -3,91 +3,57 @@ import resolve from '@rollup/plugin-node-resolve';
|
|||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import livereload from 'rollup-plugin-livereload';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import serve from 'rollup-plugin-serve';
|
||||
|
||||
import sveltePreval from 'svelte-preval';
|
||||
|
||||
const production = !process.env.ROLLUP_WATCH;
|
||||
|
||||
export default {
|
||||
input: 'src/main.js',
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: 'iife',
|
||||
name: 'app',
|
||||
file: 'public/build/bundle.js'
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
// 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: css => {
|
||||
css.write('public/build/bundle.css');
|
||||
},
|
||||
|
||||
input: 'src/main.js',
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: 'iife',
|
||||
name: 'app',
|
||||
file: 'public/build/bundle.js'
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
dev: !production,
|
||||
css: css => {
|
||||
css.write('bundle.css');
|
||||
},
|
||||
preprocess: [
|
||||
sveltePreval({
|
||||
//workDir: process.cwd(),
|
||||
baseDir: __dirname,
|
||||
// directory of rollup.config.js
|
||||
// require relative paths with
|
||||
// require(baseDir+'/path/to/script.js');
|
||||
}),
|
||||
],
|
||||
}),
|
||||
|
||||
}),
|
||||
resolve({
|
||||
browser: true,
|
||||
dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/')
|
||||
}),
|
||||
|
||||
commonjs(),
|
||||
|
||||
!production && serve({
|
||||
open: true, // open browser
|
||||
verbose: false,
|
||||
contentBase: 'public',
|
||||
// Options used in setting up server
|
||||
//host: 'localhost',
|
||||
host: '0.0.0.0', // listen on all interfaces
|
||||
port: 5000,
|
||||
}),
|
||||
|
||||
// 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: importee => importee === 'svelte' || importee.startsWith('svelte/')
|
||||
}),
|
||||
commonjs(),
|
||||
!production && livereload('public'),
|
||||
|
||||
// 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
|
||||
},
|
||||
*/
|
||||
production && terser()
|
||||
],
|
||||
watch: {
|
||||
//clearScreen: false
|
||||
chokidar: false, // push all changes to browser
|
||||
// https://github.com/sveltejs/template/issues/77
|
||||
},
|
||||
};
|
||||
|
||||
function serve() {
|
||||
let started = false;
|
||||
|
||||
return {
|
||||
writeBundle() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
|
||||
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||
stdio: ['ignore', 'inherit', 'inherit'],
|
||||
shell: true
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue