Skip to content

Instantly share code, notes, and snippets.

@brodo
Created December 4, 2019 12:46
Show Gist options
  • Save brodo/c772a307bb02b100ad89873e73111de0 to your computer and use it in GitHub Desktop.
Save brodo/c772a307bb02b100ad89873e73111de0 to your computer and use it in GitHub Desktop.
Svelte ui5-wc rollup
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 scss from 'rollup-plugin-scss'
import url from "@rollup/plugin-url";
import { terser } from 'rollup-plugin-terser';
import { string } from "rollup-plugin-string";
import json from '@rollup/plugin-json';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/bundle.js',
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file — better for performance
css: css => {
css.write('public/bundle.css');
}
}),
string({
// Required to be specified
include: "./src/**/*.graphql"
}),
resolve({
browser: true,
dedupe: importee => importee === 'svelte' || importee.startsWith('svelte/')
}),
url({
limit: 0, // inline files < 10k, copy files > 10k
include: "./node_modules/@ui5/webcomponents/dist/assets/i18n/*.json", // defaults to .svg, .png, .jpg and .gif files
fileName: "languages/[name].[hash][extname]",
publicPath: "/"
}),
commonjs(),
scss(),
json({include:[ "./src/**", "./node_modules/@ui5/webcomponents-icons/dist/assets/icon-collections/**"]}),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment