Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new skipCss option #109

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions index.ts
Expand Up @@ -28,6 +28,12 @@ interface esbuildSvelteOptions {
*/
cache?: boolean | "overzealous";

/**
* Skip including and bundling an external CSS file.
* By default css is processed according to compilerOptions.css
*/
skipCss?: boolean;

/**
* Should esbuild-svelte create a binding to an html element for components given in the entryPoints list
* Defaults to `false` for now until support is added
Expand Down Expand Up @@ -94,6 +100,11 @@ export default function sveltePlugin(options?: esbuildSvelteOptions): Plugin {
options.cache = true;
}

// process css by default
if (options.skipCss == undefined) {
options.skipCss = false;
}

// disable entry file generation by default
if (options.fromEntryFile == undefined) {
options.fromEntryFile = false;
Expand Down Expand Up @@ -223,8 +234,9 @@ export default function sveltePlugin(options?: esbuildSvelteOptions): Plugin {

let contents = js.code + `\n//# sourceMappingURL=` + toUrl(js.map.toString());

//if svelte emits css seperately, then store it in a map and import it from the js
if (!compilerOptions.css && css.code) {
// if svelte emits css seperately, then store it in a map and import it from the js
// unless we want to skip css entirely
if (!compilerOptions.css && css.code && !options?.skipCss) {
let cssPath = args.path
.replace(".svelte", ".esbuild-svelte-fake-css") //TODO append instead of replace to support different svelte filters
.replace(/\\/g, "/");
Expand Down