Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Add a loader option #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-postcss-literal",
"version": "0.2.1",
"version": "0.2.2",
"description": "PostCSS tagged template literals plugin for esbuild.",
"repository": "nativew/esbuild-plugin-postcss-literal",
"author": "Antoine Boulanger (https://github.com/antoineboulanger)",
Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const pluginPostcssLiteral = (settings = {}) => ({
namespace = '',
tag = 'css',
minify = false,
loader = 'js',
config = {}
} = settings;
let warnings;
Expand All @@ -30,7 +31,7 @@ const pluginPostcssLiteral = (settings = {}) => ({
const transformContents = async ({ args, contents }) => {
const index = contents.indexOf(tag + '`');

if (index == -1) return { contents };
if (index == -1) return { contents, loader };

const start = index + tag.length + 1;
const end = contents.indexOf('`', start);
Expand All @@ -55,7 +56,7 @@ const pluginPostcssLiteral = (settings = {}) => ({
.warnings()
.forEach(warn => process.stderr.write(warn.toString()));

return { contents };
return { contents, loader };
})
.catch(error => {
if (error.name != 'CssSyntaxError') throw error;
Expand Down