Alice Gaudon
6aa37eb9e4
Reorganize views into new "assets" folder structure
Turn locals into a store so locals don't have to be passed through files that don't need them
Some fixes to previous commit (esm) 82ab0b963c
Remove afs in favor of fs.promises (renamed afs.exists to Utils.doesFileExist
Rename Utils.readdirRecursively to Utils.listFilesRecursively
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
import path from "path";
|
|
import svelte from "rollup-plugin-svelte";
|
|
import {sveltePreprocess} from "svelte-preprocess/dist/autoProcess";
|
|
import cssOnlyRollupPlugin from "rollup-plugin-css-only";
|
|
import resolve from "@rollup/plugin-node-resolve";
|
|
import commonjs from "@rollup/plugin-commonjs";
|
|
import {terser} from "rollup-plugin-terser";
|
|
import livereloadRollupPlugin from "rollup-plugin-livereload";
|
|
|
|
const production = process.env.ENV === 'production';
|
|
const buildDir = process.env.BUILD_DIR;
|
|
const publicDir = process.env.PUBLIC_DIR;
|
|
const input = process.env.INPUT.split(':');
|
|
|
|
export default commandLineArgs => ({
|
|
input: input,
|
|
output: {
|
|
sourcemap: true,
|
|
format: 'es',
|
|
name: 'bundle',
|
|
dir: path.join(publicDir, 'js'),
|
|
entryFileNames: (chunkInfo) => {
|
|
const name = chunkInfo.facadeModuleId ?
|
|
path.relative(buildDir, chunkInfo.facadeModuleId) :
|
|
chunkInfo.name;
|
|
return name + '.js';
|
|
},
|
|
chunkFileNames: '[name].js',
|
|
},
|
|
plugins: [
|
|
svelte({
|
|
preprocess: sveltePreprocess({
|
|
typescript: {
|
|
tsconfigFile: 'tsconfig.svelte.json',
|
|
},
|
|
}),
|
|
compilerOptions: {
|
|
dev: !production,
|
|
hydratable: true,
|
|
},
|
|
}),
|
|
|
|
// Extract css into separate files
|
|
cssOnlyRollupPlugin({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(),
|
|
|
|
// Live reload in dev
|
|
!production && !!commandLineArgs.watch && livereloadRollupPlugin('public'),
|
|
|
|
// Minify in production
|
|
production && terser(),
|
|
],
|
|
watch: {
|
|
clearScreen: false,
|
|
},
|
|
});
|