New watch css files with simple file edit test
This commit is contained in:
parent
b92e8deb80
commit
81d1e9ea77
1
dist/index.esm.js
vendored
1
dist/index.esm.js
vendored
@ -64,6 +64,7 @@ const postCSSPlugin = ({
|
|||||||
return {
|
return {
|
||||||
namespace: isModule ? "postcss-module" : "file",
|
namespace: isModule ? "postcss-module" : "file",
|
||||||
path: tmpFilePath,
|
path: tmpFilePath,
|
||||||
|
watchFiles: [sourceFullPath],
|
||||||
pluginData: {
|
pluginData: {
|
||||||
originalPath: sourceFullPath
|
originalPath: sourceFullPath
|
||||||
}
|
}
|
||||||
|
|||||||
1
dist/index.js
vendored
1
dist/index.js
vendored
@ -90,6 +90,7 @@ const postCSSPlugin = ({
|
|||||||
return {
|
return {
|
||||||
namespace: isModule ? "postcss-module" : "file",
|
namespace: isModule ? "postcss-module" : "file",
|
||||||
path: tmpFilePath,
|
path: tmpFilePath,
|
||||||
|
watchFiles: [sourceFullPath],
|
||||||
pluginData: {
|
pluginData: {
|
||||||
originalPath: sourceFullPath
|
originalPath: sourceFullPath
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,16 +39,16 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "^4.2.15",
|
"@types/chai": "^4.2.15",
|
||||||
"@types/fs-extra": "^9.0.8",
|
"@types/fs-extra": "^9.0.9",
|
||||||
"@types/less": "^3.0.2",
|
"@types/less": "^3.0.2",
|
||||||
"@types/mocha": "^8.2.2",
|
"@types/mocha": "^8.2.2",
|
||||||
"@types/node": "^14.14.35",
|
"@types/node": "^14.14.37",
|
||||||
"@types/sass": "^1.16.0",
|
"@types/sass": "^1.16.0",
|
||||||
"@types/stylus": "^0.48.33",
|
"@types/stylus": "^0.48.33",
|
||||||
"@types/tmp": "^0.2.0",
|
"@types/tmp": "^0.2.0",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"esbuild": "^0.9.6",
|
"esbuild": "^0.11.2",
|
||||||
"mocha": "^8.3.2",
|
"mocha": "^8.3.2",
|
||||||
"normalize.css": "^8.0.1",
|
"normalize.css": "^8.0.1",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
|
|||||||
@ -117,6 +117,7 @@ const postCSSPlugin = ({
|
|||||||
return {
|
return {
|
||||||
namespace: isModule ? "postcss-module" : "file",
|
namespace: isModule ? "postcss-module" : "file",
|
||||||
path: tmpFilePath,
|
path: tmpFilePath,
|
||||||
|
watchFiles: [sourceFullPath],
|
||||||
pluginData: {
|
pluginData: {
|
||||||
originalPath: sourceFullPath
|
originalPath: sourceFullPath
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
const autoprefixer = require("autoprefixer"),
|
const autoprefixer = require("autoprefixer"),
|
||||||
{ build } = require("esbuild"),
|
{ build } = require("esbuild"),
|
||||||
postCSS = require("../dist"),
|
postCSS = require("../dist"),
|
||||||
{ assert } = require("chai");
|
{ assert } = require("chai"),
|
||||||
|
fs = require("fs");
|
||||||
|
|
||||||
describe("PostCSS esbuild tests", () => {
|
describe("PostCSS esbuild tests", () => {
|
||||||
it("Works with basic CSS imports", (done) => {
|
it("Works with basic CSS imports", (done) => {
|
||||||
@ -44,6 +45,38 @@ describe("PostCSS esbuild tests", () => {
|
|||||||
})
|
})
|
||||||
.catch(done);
|
.catch(done);
|
||||||
});
|
});
|
||||||
|
it("Works while waching css files", (done) => {
|
||||||
|
let notTriggerTimeout = null;
|
||||||
|
build({
|
||||||
|
entryPoints: ["tests/watch.ts"],
|
||||||
|
bundle: true,
|
||||||
|
outdir: "dist",
|
||||||
|
watch: {
|
||||||
|
onRebuild: (error, result) => {
|
||||||
|
notTriggerTimeout = null;
|
||||||
|
if (error) return done(error);
|
||||||
|
assert(result);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
postCSS.default({
|
||||||
|
plugins: [autoprefixer]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
// test if modifying the css actually triggers the onRebuild event
|
||||||
|
const data = `.Test { display: block; }`;
|
||||||
|
fs.writeFile("./styles/watch.css", data, (err) => {
|
||||||
|
if (err) return done(err);
|
||||||
|
notTriggerTimeout = setTimeout(() => {
|
||||||
|
done("Watch file not triggered!");
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => process.exit(1));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function test(entryPoint) {
|
function test(entryPoint) {
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
@test: 2em;
|
.Test {
|
||||||
|
display: block;
|
||||||
.LessClass {
|
|
||||||
height: @test;
|
|
||||||
}
|
}
|
||||||
|
|||||||
3
test/styles/watch.css
Normal file
3
test/styles/watch.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.Test {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
1
test/tests/watch.ts
Normal file
1
test/tests/watch.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import "../styles/watch.css";
|
||||||
24
yarn.lock
24
yarn.lock
@ -7,10 +7,10 @@
|
|||||||
"resolved" "https://registry.npmjs.org/@types/chai/-/chai-4.2.15.tgz"
|
"resolved" "https://registry.npmjs.org/@types/chai/-/chai-4.2.15.tgz"
|
||||||
"version" "4.2.15"
|
"version" "4.2.15"
|
||||||
|
|
||||||
"@types/fs-extra@^9.0.8":
|
"@types/fs-extra@^9.0.9":
|
||||||
"integrity" "sha512-bnlTVTwq03Na7DpWxFJ1dvnORob+Otb8xHyUqUWhqvz/Ksg8+JXPlR52oeMSZ37YEOa5PyccbgUNutiQdi13TA=="
|
"integrity" "sha512-5TqDycCl0oMzwzd1cIjSJWMKMvLCDVErle4ZTjU4EmHDURR/+yZghe6GDHMCpHtcVfq0x0gMoOM546/5TbYHrg=="
|
||||||
"resolved" "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.8.tgz"
|
"resolved" "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.9.tgz"
|
||||||
"version" "9.0.8"
|
"version" "9.0.9"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
@ -24,10 +24,10 @@
|
|||||||
"resolved" "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.2.tgz"
|
"resolved" "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.2.tgz"
|
||||||
"version" "8.2.2"
|
"version" "8.2.2"
|
||||||
|
|
||||||
"@types/node@*", "@types/node@^14.14.35":
|
"@types/node@*", "@types/node@^14.14.37":
|
||||||
"integrity" "sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag=="
|
"integrity" "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw=="
|
||||||
"resolved" "https://registry.npmjs.org/@types/node/-/node-14.14.35.tgz"
|
"resolved" "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz"
|
||||||
"version" "14.14.35"
|
"version" "14.14.37"
|
||||||
|
|
||||||
"@types/sass@^1.16.0":
|
"@types/sass@^1.16.0":
|
||||||
"integrity" "sha512-2XZovu4NwcqmtZtsBR5XYLw18T8cBCnU2USFHTnYLLHz9fkhnoEMoDsqShJIOFsFhn5aJHjweiUUdTrDGujegA=="
|
"integrity" "sha512-2XZovu4NwcqmtZtsBR5XYLw18T8cBCnU2USFHTnYLLHz9fkhnoEMoDsqShJIOFsFhn5aJHjweiUUdTrDGujegA=="
|
||||||
@ -374,10 +374,10 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"prr" "~1.0.1"
|
"prr" "~1.0.1"
|
||||||
|
|
||||||
"esbuild@^0.9.6":
|
"esbuild@^0.11.2":
|
||||||
"integrity" "sha512-F6vASxU0wT/Davt9aj2qtDwDNSkQxh9VbyO56M7PDWD+D/Vgq/rmUDGDQo7te76W5auauVojjnQr/wTu3vpaUA=="
|
"integrity" "sha512-8d5FCQrR+juXC2u9zjTQ3+IYiuFuaWyKYwmApFJLquTrYNbk36H/+MkRQeTuOJg7IjUchRX2Ulwo1zRYXZ1pUg=="
|
||||||
"resolved" "https://registry.npmjs.org/esbuild/-/esbuild-0.9.6.tgz"
|
"resolved" "https://registry.npmjs.org/esbuild/-/esbuild-0.11.2.tgz"
|
||||||
"version" "0.9.6"
|
"version" "0.11.2"
|
||||||
|
|
||||||
"escalade@^3.1.1":
|
"escalade@^3.1.1":
|
||||||
"integrity" "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw=="
|
"integrity" "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw=="
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user