2019-05-19 03:59:26 +02:00
|
|
|
import resolve from 'rollup-plugin-node-resolve'
|
2019-11-19 17:18:42 +01:00
|
|
|
import replace from '@rollup/plugin-replace'
|
2019-05-19 03:59:26 +02:00
|
|
|
import commonjs from 'rollup-plugin-commonjs'
|
2019-11-19 17:18:42 +01:00
|
|
|
import svelte from 'rollup-plugin-svelte'
|
|
|
|
import babel from 'rollup-plugin-babel'
|
2019-11-21 02:50:00 +01:00
|
|
|
import json from '@rollup/plugin-json'
|
2019-05-19 03:59:26 +02:00
|
|
|
import { terser } from 'rollup-plugin-terser'
|
2019-11-19 17:18:42 +01:00
|
|
|
import config from 'sapper/config/rollup.js'
|
|
|
|
|
|
|
|
import pkg from './package.json'
|
|
|
|
|
|
|
|
const mode = process.env.NODE_ENV
|
|
|
|
const dev = mode === 'development'
|
|
|
|
const legacy = !!process.env.SAPPER_LEGACY_BUILD
|
2019-05-19 03:59:26 +02:00
|
|
|
|
2020-01-14 01:44:08 +01:00
|
|
|
const onwarn = (warning, onwarn) => {
|
|
|
|
if (
|
|
|
|
(warning.code === 'CIRCULAR_DEPENDENCY' &&
|
|
|
|
/[/\\]@sapper[/\\]/.test(warning.message)) ||
|
|
|
|
warning.code === 'THIS_IS_UNDEFINED'
|
|
|
|
) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-11-19 17:18:42 +01:00
|
|
|
onwarn(warning)
|
2020-01-14 01:44:08 +01:00
|
|
|
}
|
|
|
|
|
2019-11-19 17:18:42 +01:00
|
|
|
const dedupe = importee =>
|
|
|
|
importee === 'svelte' || importee.startsWith('svelte/')
|
2019-05-19 03:59:26 +02:00
|
|
|
|
|
|
|
export default {
|
2019-11-19 17:18:42 +01:00
|
|
|
client: {
|
|
|
|
input: config.client.input(),
|
|
|
|
output: config.client.output(),
|
|
|
|
plugins: [
|
|
|
|
replace({
|
|
|
|
'process.browser': true,
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
|
|
}),
|
|
|
|
svelte({
|
|
|
|
dev,
|
|
|
|
hydratable: true,
|
|
|
|
emitCss: true,
|
|
|
|
}),
|
|
|
|
resolve({
|
|
|
|
browser: true,
|
|
|
|
dedupe,
|
|
|
|
}),
|
|
|
|
commonjs(),
|
2019-11-21 02:24:29 +01:00
|
|
|
json({
|
|
|
|
namedExports: false,
|
|
|
|
compact: !dev,
|
|
|
|
}),
|
2019-11-19 17:18:42 +01:00
|
|
|
legacy &&
|
|
|
|
babel({
|
|
|
|
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
|
|
|
runtimeHelpers: true,
|
|
|
|
exclude: ['node_modules/@babel/**'],
|
2019-11-21 02:24:29 +01:00
|
|
|
presets: [['@babel/preset-env', { targets: '> 0.25%, not dead' }]],
|
2019-11-19 17:18:42 +01:00
|
|
|
plugins: [
|
|
|
|
'@babel/plugin-syntax-dynamic-import',
|
2019-11-21 02:24:29 +01:00
|
|
|
['@babel/plugin-transform-runtime', { useESModules: true }],
|
2019-11-19 17:18:42 +01:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
|
|
|
|
!dev &&
|
|
|
|
terser({
|
|
|
|
module: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
|
|
|
|
onwarn,
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
input: config.server.input(),
|
|
|
|
output: config.server.output(),
|
|
|
|
plugins: [
|
|
|
|
replace({
|
|
|
|
'process.browser': false,
|
|
|
|
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
|
|
}),
|
|
|
|
svelte({
|
|
|
|
generate: 'ssr',
|
|
|
|
dev,
|
|
|
|
}),
|
|
|
|
resolve({
|
|
|
|
dedupe,
|
|
|
|
}),
|
|
|
|
commonjs(),
|
2019-11-21 02:24:29 +01:00
|
|
|
json({
|
|
|
|
namedExports: false,
|
|
|
|
compact: !dev,
|
|
|
|
}),
|
2019-11-19 17:18:42 +01:00
|
|
|
],
|
|
|
|
external: Object.keys(pkg.dependencies).concat(
|
|
|
|
require('module').builtinModules ||
|
2019-11-20 20:31:55 +01:00
|
|
|
Object.keys(process.binding('natives'))
|
2019-11-19 17:18:42 +01:00
|
|
|
),
|
|
|
|
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,
|
2019-05-19 03:59:26 +02:00
|
|
|
},
|
|
|
|
}
|