Files
housesof/rollup.config.js
Félix Péault 2064885997 WIP Interactive globe from Nico's sources
- The globe is a bit small? Ability to control the max-min size potentially
- Is there a reason why `globe.update()` runs every second? Sounds like a lot of resources?
- Have the ability to control the `addEventListener` of the markers to do whatever (in this case, going to a route by clicking on a link with a sapper-noscroll attribute + changing the href attribute on click - the method `goto` from Sapper scrolls back to top / maybe something to fix with the current transition issues?)
- Edited in `./index.js`:
    1. Using the class as `export default WebglGlobe` instead of Window (as Svelte or Sapper doesn't likayt)
- Edited in `Camera.js`:
    1. Commented line 218: `e.preventDefault();` would cause this error: `[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See <URL>`
2020-04-02 20:59:40 +02:00

150 lines
4.1 KiB
JavaScript

import path from 'path'
import resolve from '@rollup/plugin-node-resolve'
import alias from '@rollup/plugin-alias'
import replace from '@rollup/plugin-replace'
import commonjs from '@rollup/plugin-commonjs'
import svelte from 'rollup-plugin-svelte'
import babel from 'rollup-plugin-babel'
// import { eslint } from 'rollup-plugin-eslint'
// import browsersync from 'rollup-plugin-browsersync'
import autoPreprocess from 'svelte-preprocess'
import { terser } from 'rollup-plugin-terser'
import glslify from 'rollup-plugin-glslify'
import sapperConfig from 'sapper/config/rollup'
import { config } from 'dotenv'
import pkg from './package.json'
// Define environment and things
const mode = process.env.NODE_ENV
const dev = mode === 'development'
const legacy = !!process.env.SAPPER_LEGACY_BUILD
const replaceOptions = {
'process.env.NODE_ENV': JSON.stringify(mode),
'process.env.CONFIG': JSON.stringify(config().parsed)
}
// Svelte
const onwarn = (warning, onwarn) => (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) || onwarn(warning)
// Preprocessors
const preprocess = autoPreprocess({
scss: {
includePaths: ['src', 'node_modules'],
renderSync: true
},
postcss: true
})
// Resolve and Alias
const resolveExtensions = ['.mjs', '.js', '.svelte', '.scss', '.json', '.html']
const aliases = alias({
resolve: resolveExtensions,
entries: [
{ find: 'utils', replacement: path.resolve(__dirname, 'src/utils') },
{ find: 'animations', replacement: path.resolve(__dirname, 'src/animations') },
{ find: 'atoms', replacement: path.resolve(__dirname, 'src/atoms') },
{ find: 'molecules', replacement: path.resolve(__dirname, 'src/molecules') },
{ find: 'organisms', replacement: path.resolve(__dirname, 'src/organisms') },
{ find: 'globe', replacement: path.resolve(__dirname, 'src/globe') },
]
})
export default {
/*
** Client
*/
client: {
input: sapperConfig.client.input(),
output: sapperConfig.client.output(),
plugins: [
// Javascript
replace({
'process.browser': true,
...replaceOptions
}),
svelte({
dev,
preprocess,
hydratable: true,
emitCss: true,
// css: css => css.write('static/bundle.css')
}),
aliases,
glslify(),
resolve({
browser: true,
extensions: resolveExtensions,
dedupe: ['svelte']
}),
commonjs(),
// dev && eslint(),
legacy && babel({
extensions: resolveExtensions,
exclude: ['*.scss', '*.css', 'node_modules/@babel/**'],
runtimeHelpers: true
}),
// Compress Javascript
!dev && terser({
module: true
}),
],
onwarn,
},
/*
** Server
*/
server: {
input: sapperConfig.server.input(),
output: sapperConfig.server.output(),
plugins: [
replace({
'process.browser': false,
...replaceOptions
}),
svelte({
dev,
preprocess,
generate: 'ssr'
}),
aliases,
glslify(),
resolve({
browser: true,
extensions: resolveExtensions,
dedupe: ['svelte']
}),
commonjs()
],
external: Object.keys(pkg.dependencies).concat(
require('module').builtinModules || Object.keys(process.binding('natives'))
),
onwarn,
},
/*
** Service worker
*/
// serviceworker: {
// input: sapperConfig.serviceworker.input(),
// output: sapperConfig.serviceworker.output(),
// plugins: [
// resolve(),
// aliases,
// replace({
// 'process.browser': true,
// ...replaceOptions
// }),
// commonjs(),
// !dev && terser()
// ],
// onwarn,
// }
}