Last active
May 31, 2019 20:59
-
-
Save mattpilott/f50b67b71c8ae56d0224c9127bd3d7e4 to your computer and use it in GitHub Desktop.
This file contains 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 babel from "rollup-plugin-babel"; | |
import { terser } from "rollup-plugin-terser"; | |
import config from "sapper/config/rollup.js"; | |
import pkg from "./package.json"; | |
import sveltePreprocess from "svelte-preprocess"; | |
import autoprefixer from "autoprefixer"; | |
import alias from "rollup-plugin-alias"; | |
import path from "path"; | |
const mode = process.env.NODE_ENV; | |
const dev = mode === "development"; | |
const legacy = !!process.env.SAPPER_LEGACY_BUILD; | |
const preprocess = sveltePreprocess({ | |
transformers: { | |
scss: { sourceMap: false }, | |
postcss: { plugins: [autoprefixer] } | |
} | |
}); | |
export default { | |
client: { | |
input: config.client.input(), | |
output: config.client.output(), | |
plugins: [ | |
replace({ | |
"process.browser": true, | |
"process.env.NODE_ENV": JSON.stringify(mode), | |
"pkg.version": JSON.stringify(pkg.version) | |
}), | |
svelte({ | |
dev, | |
hydratable: true, | |
emitCss: true, | |
preprocess | |
}), | |
resolve({ browser: true }), | |
commonjs(), | |
alias({ | |
resolve: [".js", ".mjs", ".html", ".svelte"], | |
"~": path.join(__dirname, "./src") | |
}), | |
legacy && | |
babel({ | |
extensions: [".js", ".mjs", ".html", ".svelte"], | |
runtimeHelpers: true, | |
exclude: ["node_modules/@babel/**"], | |
presets: [["@babel/preset-env"]], | |
plugins: [ | |
"@babel/plugin-syntax-dynamic-import", | |
[ | |
"@babel/plugin-transform-runtime", | |
{ | |
useESModules: true | |
} | |
] | |
] | |
}), | |
!dev && | |
terser({ | |
module: true, | |
numWorkers: 1 | |
}) | |
], | |
onwarn(message, warn) { | |
if (/@sapper/.test(message)) return; | |
if (/svelte-transitions/.test(message)) return; | |
if (/eases-jsnext/.test(message)) return; | |
warn(message); | |
} | |
}, | |
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, | |
preprocess | |
}), | |
resolve(), | |
commonjs(), | |
alias({ | |
resolve: [".js", ".mjs", ".html", ".svelte"], | |
"~": path.join(__dirname, "./src") | |
}) | |
], | |
external: Object.keys(pkg.dependencies).concat( | |
require("module").builtinModules || | |
Object.keys(process.binding("natives")) | |
), | |
onwarn(message, warn) { | |
if (/@sapper/.test(message)) return; | |
if (/svelte-transitions/.test(message)) return; | |
if (/eases-jsnext/.test(message)) return; | |
warn(message); | |
} | |
}, | |
serviceworker: { | |
input: config.serviceworker.input(), | |
output: config.serviceworker.output(), | |
plugins: [ | |
resolve(), | |
replace({ | |
"process.browser": true, | |
"process.env.NODE_ENV": JSON.stringify(mode) | |
}), | |
commonjs(), | |
alias({ | |
resolve: [".js", ".mjs", ".html", ".svelte"], | |
"~": path.join(__dirname, "./src") | |
}), | |
!dev && terser({ numWorkers: 1 }) | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment