Last active
November 14, 2019 09:24
-
-
Save nltesown/08cfb2acd9c48f954a27e4491101dfb4 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 svelte from "rollup-plugin-svelte"; | |
import resolve from "rollup-plugin-node-resolve"; | |
import commonjs from "rollup-plugin-commonjs"; | |
import livereload from "rollup-plugin-livereload"; | |
import { terser } from "rollup-plugin-terser"; | |
import postcss from "postcss"; | |
import postcssImport from "postcss-import"; | |
import postcssPresetEnv from "postcss-preset-env"; | |
import lost from "lost"; | |
const production = !process.env.ROLLUP_WATCH; | |
export default { | |
input: "src/main.js", | |
output: { | |
sourcemap: true, | |
format: "iife", | |
name: "app", | |
file: "public/js/bundle.js" | |
}, | |
plugins: [ | |
svelte({ | |
dev: !production, | |
css: css => { | |
css.write("public/css/bundle.css"); | |
}, | |
preprocess: { | |
style: ({ content, attributes }) => { | |
if (attributes.type !== "text/postcss") { | |
return; | |
} | |
return postcss([postcssImport, lost, postcssPresetEnv]) | |
.process(content, { | |
from: "src", | |
map: { | |
inline: false | |
} | |
}) | |
.then(result => ({ | |
code: result.css.toString(), | |
map: result.map.toString() | |
})); | |
} | |
} | |
}), | |
resolve({ | |
browser: true | |
}), | |
commonjs(), | |
!production && livereload("public"), | |
production && terser() | |
], | |
watch: { | |
clearScreen: false | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment