forked from svelteness/svelte-jester
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: auto-preprocess instead of loading svelte.config.js
- Loading branch information
1 parent
bd0520e
commit a38d68b
Showing
1 changed file
with
5 additions
and
4 deletions.
There are no files selected for viewing
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
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) }) |