Skip to content

Commit

Permalink
perf: move svelte config to svelte plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Oct 26, 2020
1 parent 754eb29 commit b27abab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/plugins/rollup/rollup.template.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

const svelte = require('rollup-plugin-svelte-hot')
const resolve = require('@rollup/plugin-node-resolve').default
const commonjs = require('@rollup/plugin-commonjs')
const { terser } = require('rollup-plugin-terser')
Expand All @@ -24,9 +23,8 @@ module.exports = function rollup(app, params) {
sourcemap: true,
format: 'esm', dir: buildDir
},
plugins$map: { svelte, resolve, commonjs, terser, hmr, livereload },
plugins$map: { resolve, commonjs, terser, hmr, livereload },
plugins$options: {
svelte: app.config.svelte,
// resolve matching modules from current working directory
resolve: {
browser: true,
Expand Down
21 changes: 17 additions & 4 deletions lib/plugins/svelte/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@

import svelte from 'rollup-plugin-svelte-hot'

export default {
hooks: [
{
event: 'start',
action: async (app, params, ctx) => {
const { production } = app.state

const config = {
dev: !production, // run-time checks
hot: !production && { optimistic: true, noPreserveState: false },
extensions: ['.svelte'],
preprocess$options: {},
preprocess$map: {}
}

app.merge({
config: {
svelte: {
extensions: ['.svelte'],
preprocess$options: {},
preprocess$map: {}
svelte: config,
rollup: {
plugins$options: { svelte: config },
plugins$map: { svelte }
}
}
})
Expand Down

0 comments on commit b27abab

Please sign in to comment.