-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1361a06
commit 5e43218
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const fs = require("fs"); | ||
const chokidar = require("chokidar"); | ||
const postcss = require("postcss"); | ||
const postcssComponents = require("../../components-package/postcss.components"); | ||
|
||
const srcFiles = process.argv[2]; | ||
|
||
const run = path => { | ||
fs.readFile(path, (err, css) => { | ||
postcss(postcssComponents.plugins) | ||
.process(css, { from: path }) | ||
.then(result => { | ||
console.log("Processed: ", path); | ||
}); | ||
}); | ||
}; | ||
|
||
let ready = false; // Do nothing until the ready event has been fired (we don't want to recompile all files initially) | ||
|
||
const watcher = chokidar.watch(srcFiles); | ||
|
||
watcher.on("ready", () => { | ||
ready = true; // Initial scan is over -> waiting for changes or new files | ||
}); | ||
watcher.on("add", path => { | ||
if (ready) { | ||
run(path); | ||
} | ||
}); | ||
watcher.on("change", path => { | ||
if (ready) { | ||
run(path); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2522,7 +2522,7 @@ [email protected]: | |
optionalDependencies: | ||
fsevents "~2.1.2" | ||
|
||
[email protected], chokidar@^3.0.0, chokidar@^3.2.3, chokidar@^3.3.0, chokidar@^3.4.0, chokidar@^3.5.0: | ||
[email protected], chokidar@^3.0.0, chokidar@^3.2.3, chokidar@^3.3.0, chokidar@^3.4.0, chokidar@^3.5.0, chokidar@^3.5.1: | ||
version "3.5.1" | ||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" | ||
integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== | ||
|