Fix to resolve entry points
This commit is contained in:
parent
68340d405f
commit
a842d7daa5
13
src/index.ts
13
src/index.ts
@ -56,8 +56,10 @@ const postCSSPlugin = ({
|
||||
});
|
||||
|
||||
build.onResolve(
|
||||
{ filter: /.\.(css|sass|scss|less|styl)$/, namespace: "file" },
|
||||
{ filter: /.\.(css|sass|scss|less|styl)$/ },
|
||||
async (args) => {
|
||||
if (args.namespace !== "file" && args.namespace !== "") return;
|
||||
|
||||
const sourceFullPath = path.resolve(args.resolveDir, args.path),
|
||||
sourceExt = path.extname(sourceFullPath),
|
||||
sourceBaseName = path.basename(sourceFullPath, sourceExt),
|
||||
@ -65,13 +67,10 @@ const postCSSPlugin = ({
|
||||
sourceRelDir = path.relative(path.dirname(rootDir), sourceDir),
|
||||
isModule = sourceBaseName.match(/\.module$/),
|
||||
tmpDir = path.resolve(tmpDirPath, sourceRelDir),
|
||||
tmpFilePath = path.resolve(
|
||||
tmpDir,
|
||||
`${sourceBaseName}-tmp-${Date.now()}-${sourceExt.replace(".", "")}${
|
||||
isModule ? ".module" : ""
|
||||
}.css`
|
||||
);
|
||||
tmpFilePath = path.resolve(tmpDir, `${sourceBaseName}.css`);
|
||||
|
||||
console.log(tmpDir);
|
||||
console.log(tmpFilePath);
|
||||
await ensureDir(tmpDir);
|
||||
|
||||
const fileContent = await readFile(sourceFullPath);
|
||||
|
||||
@ -5,7 +5,7 @@ const autoprefixer = require("autoprefixer"),
|
||||
|
||||
describe("PostCSS esbuild tests", () => {
|
||||
it("Works with basic CSS imports", (done) => {
|
||||
test("basic")
|
||||
test("tests/basic.ts")
|
||||
.then((res) => {
|
||||
assert(res);
|
||||
done();
|
||||
@ -13,7 +13,7 @@ describe("PostCSS esbuild tests", () => {
|
||||
.catch(done);
|
||||
});
|
||||
it("Works with preprocessors", (done) => {
|
||||
test("preprocessors")
|
||||
test("tests/preprocessors.ts")
|
||||
.then((res) => {
|
||||
assert(res);
|
||||
done();
|
||||
@ -21,7 +21,15 @@ describe("PostCSS esbuild tests", () => {
|
||||
.catch(done);
|
||||
});
|
||||
it("Works with CSS modules", (done) => {
|
||||
test("modules")
|
||||
test("tests/modules.ts")
|
||||
.then((res) => {
|
||||
assert(res);
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
it("Works with CSS as entrypoint", (done) => {
|
||||
test("tests/styles.css")
|
||||
.then((res) => {
|
||||
assert(res);
|
||||
done();
|
||||
@ -30,9 +38,9 @@ describe("PostCSS esbuild tests", () => {
|
||||
});
|
||||
});
|
||||
|
||||
function test(test) {
|
||||
function test(entryPoint) {
|
||||
return build({
|
||||
entryPoints: [`tests/${test}.ts`],
|
||||
entryPoints: [entryPoint],
|
||||
bundle: true,
|
||||
outdir: "dist",
|
||||
plugins: [
|
||||
|
||||
6
test/tests/styles.css
Normal file
6
test/tests/styles.css
Normal file
@ -0,0 +1,6 @@
|
||||
.example {
|
||||
display: grid;
|
||||
transition: all 0.5s;
|
||||
user-select: none;
|
||||
background: linear-gradient(to bottom, white, black);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user