Skip to content

Commit

Permalink
fix: auto-preprocess instead of loading svelte.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jun 10, 2020
1 parent bd0520e commit a38d68b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/preprocess.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const path = require('path')
const svelte = require('svelte/compiler')
const { cosmiconfigSync } = require('cosmiconfig')

const { source, filename } = process.env
const configPath = path.join(process.cwd(), 'svelte.config.js')
const config = cosmiconfigSync().load(configPath).config

// TODO: loading svelte.config.js fails if you are in "type":"module"
// So just load svelte-preprocess directly
const preprocess = require('svelte-preprocess')

svelte
.preprocess(source, config.preprocess || {}, { filename })
.preprocess(source, preprocess(), { filename })
.then(r => { process.stdout.write(r.code) })

0 comments on commit a38d68b

Please sign in to comment.