Skip to content

Commit

Permalink
Formatting, Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Jan 10, 2024
1 parent 1a1560c commit 2f91cbb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
30 changes: 29 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,39 @@
"index": "deno run --check --unstable -A ./src/index.ts"
},
"exclude": [
"**/*.test.ts"
"./dist/"
],
"test": {
"include": [
"**/*.test.ts"
]
},
"compilerOptions": {
"experimentalDecorators": true,
"target": "ES6",
"module": "ES6"
},
"fmt": {
"singleQuote": true,
"lineWidth": 120,
"indentWidth": 2
},
"lint": {
"rules": {
"tags": [
"recommended"
],
"include": [
"camelcase",
"default-param-last",
"eqeqeq",
"explicit-function-return-type",
"explicit-module-boundary-types",
"guard-for-in",
"no-eval",
"no-sparse-arrays",
"prefer-ascii"
]
}
}
}
2 changes: 2 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import sassPlugin from './src/index.ts';

export default sassPlugin;
6 changes: 3 additions & 3 deletions src/get_text_content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
export default function getTextContent(css: string | false | Map<string, string>): string {
if (css instanceof Map) {
return css.get("index") || "";
} else if (typeof css === "string") {
return css.get('index') || '';
} else if (typeof css === 'string') {
return css;
}
return "";
return '';
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Plugin as ESBuildPlugin } from "https://deno.land/x/[email protected]/mod.js";
import sassPluginSetup from "./sass_plugin_setup.ts";
import { Plugin as ESBuildPlugin } from 'https://deno.land/x/[email protected]/mod.js';
import sassPluginSetup from './sass_plugin_setup.ts';

/**
* The main plugin object.
Expand All @@ -8,7 +8,7 @@ import sassPluginSetup from "./sass_plugin_setup.ts";
*/
export default function sassPlugin(): ESBuildPlugin {
return {
name: "esbuild-plugin-sass",
name: 'esbuild-plugin-sass',
setup: (build) =>
sassPluginSetup(
build.initialOptions,
Expand Down
10 changes: 5 additions & 5 deletions src/sass_plugin_setup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sass from 'https://deno.land/x/[email protected]/mod.ts';
import {
BuildOptions,
OnLoadArgs,
OnLoadOptions,
OnLoadResult,
} from "https://deno.land/x/[email protected]/mod.js";
import sass from "https://deno.land/x/[email protected]/mod.ts";
import getTextContent from "./get_text_content.ts";
} from 'https://deno.land/x/[email protected]/mod.js';
import getTextContent from './get_text_content.ts';

/**
* This function registers the onLoad function and sets some initial options.
Expand All @@ -31,12 +31,12 @@ export default function sassPluginSetup(
async (args) => {
const file = await Deno.readTextFile(args.path);
const css = sass(file, {
style: initialOptions.minify ? "compressed" : "expanded",
style: initialOptions.minify ? 'compressed' : 'expanded',
}).to_string();

return {
contents: getTextContent(css),
loader: "css",
loader: 'css',
};
},
);
Expand Down

0 comments on commit 2f91cbb

Please sign in to comment.