|
|
@@ -1,12 +1,13 @@ |
|
|
|
import svelte from 'rollup-plugin-svelte'; |
|
|
|
import resolve from '@rollup/plugin-node-resolve'; |
|
|
|
import commonjs from '@rollup/plugin-commonjs'; |
|
|
|
import typescript from '@rollup/plugin-typescript'; |
|
|
|
import json from '@rollup/plugin-json'; |
|
|
|
import replace from '@rollup/plugin-replace'; |
|
|
|
import livereload from 'rollup-plugin-livereload'; |
|
|
|
import { terser } from 'rollup-plugin-terser'; |
|
|
|
import preprocess from 'svelte-preprocess'; |
|
|
|
import { mdsvex } from 'mdsvex'; |
|
|
|
import typescript from '@rollup/plugin-typescript'; |
|
|
|
|
|
|
|
const production = !process.env.ROLLUP_WATCH; |
|
|
|
|
|
|
@@ -31,7 +32,31 @@ function serve() { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
export default { |
|
|
|
const sharedPlugins = (opts) => [ |
|
|
|
svelte(Object.assign({ |
|
|
|
hydratable: true, |
|
|
|
extensions: ['.svelte', '.svx'], |
|
|
|
// 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'); |
|
|
|
}, |
|
|
|
preprocess: [ |
|
|
|
preprocess(), |
|
|
|
mdsvex() |
|
|
|
] |
|
|
|
}, opts.svelte || {})), |
|
|
|
commonjs(), |
|
|
|
typescript({ |
|
|
|
tsconfig: opts.tsconfig || 'tsconfig.json', |
|
|
|
sourceMap: !production |
|
|
|
}), |
|
|
|
json() |
|
|
|
]; |
|
|
|
|
|
|
|
export default [{ |
|
|
|
input: 'src/main.ts', |
|
|
|
output: { |
|
|
|
sourcemap: true, |
|
|
@@ -40,21 +65,6 @@ export default { |
|
|
|
file: 'public/build/bundle.js' |
|
|
|
}, |
|
|
|
plugins: [ |
|
|
|
svelte({ |
|
|
|
extensions: ['.svelte', '.svx'], |
|
|
|
// 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'); |
|
|
|
}, |
|
|
|
preprocess: [ |
|
|
|
preprocess(), |
|
|
|
mdsvex() |
|
|
|
] |
|
|
|
}), |
|
|
|
|
|
|
|
// If you have external dependencies installed from |
|
|
|
// npm, you'll most likely need these plugins. In |
|
|
|
// some cases you'll need additional configuration - |
|
|
@@ -64,13 +74,8 @@ export default { |
|
|
|
browser: true, |
|
|
|
dedupe: ['svelte'] |
|
|
|
}), |
|
|
|
commonjs(), |
|
|
|
typescript({ sourceMap: !production }), |
|
|
|
json(), |
|
|
|
|
|
|
|
// In dev mode, call `npm run start` once |
|
|
|
// the bundle has been generated |
|
|
|
!production && serve(), |
|
|
|
...sharedPlugins({}), |
|
|
|
|
|
|
|
// Watch the `public` directory and refresh the |
|
|
|
// browser on changes when not in production |
|
|
@@ -83,4 +88,46 @@ export default { |
|
|
|
watch: { |
|
|
|
clearScreen: false |
|
|
|
} |
|
|
|
}; |
|
|
|
},{ |
|
|
|
input: ['src/main.ts', 'src/App.svelte'], |
|
|
|
output: { |
|
|
|
format: 'cjs', |
|
|
|
name: 'main', |
|
|
|
dir: 'server/build/' |
|
|
|
}, |
|
|
|
plugins: [ |
|
|
|
replace({ |
|
|
|
"App.svelte": "App.js" |
|
|
|
}), |
|
|
|
resolve(), |
|
|
|
...sharedPlugins({ |
|
|
|
tsconfig: "tsconfig.server.json", |
|
|
|
svelte: { generate: 'ssr' } |
|
|
|
}) |
|
|
|
], |
|
|
|
external: ['fs', 'path', 'http'] |
|
|
|
},{ |
|
|
|
input: 'server/index.ts', |
|
|
|
output: { |
|
|
|
format: 'cjs', |
|
|
|
name: 'server', |
|
|
|
dir: 'server/build/' |
|
|
|
}, |
|
|
|
plugins: [ |
|
|
|
replace({ |
|
|
|
"'../public/": "'../../public/", |
|
|
|
"../src/": "./", |
|
|
|
delimiters: ['', ''] |
|
|
|
}), |
|
|
|
resolve(), |
|
|
|
...sharedPlugins({ |
|
|
|
tsconfig: "tsconfig.server.json", |
|
|
|
svelte: { generate: 'ssr' } |
|
|
|
}), |
|
|
|
|
|
|
|
// In dev mode, call `npm run start` once |
|
|
|
// the bundle has been generated |
|
|
|
!production && serve() |
|
|
|
], |
|
|
|
external: ['fs', 'path', 'http'] |
|
|
|
}]; |