diff --git a/package.json b/package.json index ea4ecc8..9afde1f 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,12 @@ "name": "arne-drums", "version": "1.0.0", "description": "Drum beat visualiser and editor", - "main": "main.ts", + "main": "src/main.ts", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "rollup -c", + "dev": "rollup -c -w", + "start": "sirv public --no-clear", + "validate": "svelte-check" }, "repository": { "type": "git", @@ -12,7 +15,22 @@ }, "author": "Daniel Ledda", "license": "ISC", - "dependencies": { - "svelte": "^3.42.1" + "devDependencies": { + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-node-resolve": "^11.0.0", + "@rollup/plugin-typescript": "^8.0.0", + "@tsconfig/svelte": "^1.0.0", + "rollup": "^2.3.4", + "rollup-plugin-css-only": "^3.1.0", + "rollup-plugin-livereload": "^2.0.0", + "rollup-plugin-svelte": "^7.0.0", + "rollup-plugin-terser": "^7.0.0", + "svelte": "^3.0.0", + "svelte-check": "^1.0.0", + "svelte-preprocess": "^4.0.0", + "tslib": "^2.0.0" + "sirv-cli": "^1.0.0", + "typescript": "^4.4.0-dev.20210525" + "source-map-support": "^0.5.19" } -} +} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..fcd61d3 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,83 @@ +import svelte from 'rollup-plugin-svelte'; +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 sveltePreprocess from 'svelte-preprocess'; +import typescript from '@rollup/plugin-typescript'; +import css from 'rollup-plugin-css-only'; + +const production = !process.env.ROLLUP_WATCH; + +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.ts', + output: { + sourcemap: true, + format: 'iife', + name: 'app', + file: 'public/build/bundle.js' + }, + plugins: [ + svelte({ + preprocess: sveltePreprocess({ sourceMap: !production }), + 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(), + typescript({ + sourceMap: !production, + inlineSources: !production + }), + + // 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 + } +}; diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..e8236ee --- /dev/null +++ b/src/main.ts @@ -0,0 +1,10 @@ +import App from './ui/App.svelte'; + +const app = new App({ + target: document.body, + props: { + scene: new PolycubeScene() + } +}); + +export default app; \ No newline at end of file diff --git a/src/ui/App.svelte b/src/ui/App.svelte new file mode 100644 index 0000000..899e4b5 --- /dev/null +++ b/src/ui/App.svelte @@ -0,0 +1,12 @@ + + +