Created
January 17, 2020 21:41
-
-
Save rob-balfre/6cdd31547d250385a1ec049b8eea8437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resolve from 'rollup-plugin-node-resolve'; | |
import replace from 'rollup-plugin-replace'; | |
import commonjs from 'rollup-plugin-commonjs'; | |
import svelte from 'rollup-plugin-svelte'; | |
import { terser } from 'rollup-plugin-terser'; | |
import config from 'sapper/config/rollup.js'; | |
import pkg from './package.json'; | |
import alias from '@rollup/plugin-alias'; | |
const path = require('path'); | |
const mode = process.env.NODE_ENV; | |
const dev = mode === 'development'; | |
const onwarn = (warning, onwarn) => (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) || onwarn(warning); | |
const dedupe = importee => importee === 'svelte' || importee.startsWith('svelte/'); | |
const aliases = [ ... ] | |
export default { | |
client: { | |
input: config.client.input(), | |
output: config.client.output(), | |
plugins: [ | |
alias({ | |
resolve: ['.svelte', '.js'], | |
entries: aliases | |
}), | |
replace({ | |
'process.browser': true, | |
'process.env.NODE_ENV': JSON.stringify(mode) | |
}), | |
svelte({ | |
dev, | |
hydratable: true, | |
emitCss: true | |
}), | |
resolve({ | |
browser: true, | |
dedupe | |
}), | |
commonjs(), | |
!dev && terser({ | |
module: true | |
}) | |
], | |
onwarn, | |
}, | |
server: { | |
input: config.server.input(), | |
output: config.server.output(), | |
plugins: [ | |
alias({ | |
resolve: ['.svelte', '.js'], | |
entries: aliases | |
}), | |
replace({ | |
'process.browser': false, | |
'process.env.NODE_ENV': JSON.stringify(mode) | |
}), | |
svelte({ | |
generate: 'ssr', | |
dev | |
}), | |
resolve({ | |
dedupe | |
}), | |
commonjs() | |
], | |
external: Object.keys(pkg.dependencies).concat( | |
require('module').builtinModules || Object.keys(process.binding('natives')) | |
), | |
onwarn, | |
}, | |
serviceworker: { | |
input: config.serviceworker.input(), | |
output: config.serviceworker.output(), | |
plugins: [ | |
resolve(), | |
replace({ | |
'process.browser': true, | |
'process.env.NODE_ENV': JSON.stringify(mode) | |
}), | |
commonjs(), | |
!dev && terser() | |
], | |
onwarn, | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment