chokibasic 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +8 -3
- package/src/watcher.js +20 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Maxime Larrivée-Roy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chokibasic",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Basic chokidar watcher + esbuild + sass + csso helpers",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "Basic chokidar watcher + pxpros + esbuild + sass + csso helpers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"index.d.ts",
|
|
10
|
+
"src/"
|
|
11
|
+
],
|
|
8
12
|
"scripts": {
|
|
9
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
14
|
},
|
|
@@ -30,6 +34,7 @@
|
|
|
30
34
|
"chokidar": "^5.0.0",
|
|
31
35
|
"csso": "^5.0.5",
|
|
32
36
|
"esbuild": "^0.27.3",
|
|
37
|
+
"pxpros": "^1.0.0",
|
|
33
38
|
"sass": "^1.97.3"
|
|
34
39
|
}
|
|
35
40
|
}
|
package/src/watcher.js
CHANGED
|
@@ -4,6 +4,7 @@ const path = require("path");
|
|
|
4
4
|
const esbuild = require("esbuild");
|
|
5
5
|
const sass = require("sass");
|
|
6
6
|
const csso = require("csso");
|
|
7
|
+
const pxpros = require("pxpros");
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
function toPosix(p) {
|
|
@@ -205,7 +206,7 @@ function createWatchers(rules, options = {}) {
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
|
|
208
|
-
const buildCSS = async (inputScss, outCssMin) => {
|
|
209
|
+
const buildCSS = async (inputScss, outCssMin, options = {}) => {
|
|
209
210
|
let compiled;
|
|
210
211
|
try {
|
|
211
212
|
compiled = sass.compile(inputScss, {
|
|
@@ -213,18 +214,19 @@ const buildCSS = async (inputScss, outCssMin) => {
|
|
|
213
214
|
style: "compressed",
|
|
214
215
|
sourceMap: false,
|
|
215
216
|
sourceMapIncludeSources: false,
|
|
217
|
+
...options
|
|
216
218
|
});
|
|
219
|
+
const minified = csso.minify(compiled.css, { restructure: false });
|
|
220
|
+
fs.writeFileSync(outCssMin, minified.css);
|
|
221
|
+
console.log(`✅ CSS generated: ${outCssMin}`);
|
|
217
222
|
} catch (err) {
|
|
218
223
|
console.error("❌ Sass compile error:");
|
|
219
224
|
console.error(err?.formatted || err?.message || err);
|
|
220
225
|
}
|
|
221
|
-
const minified = csso.minify(compiled.css, { restructure: false });
|
|
222
|
-
fs.writeFileSync(outCssMin, minified.css);
|
|
223
|
-
console.log(`✅ CSS generated: ${outCssMin}`);
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
|
|
227
|
-
const buildJS = async (entry, outfile) => {
|
|
229
|
+
const buildJS = async (entry, outfile, options = {}) => {
|
|
228
230
|
try {
|
|
229
231
|
await esbuild.build({
|
|
230
232
|
entryPoints: [entry],
|
|
@@ -237,6 +239,7 @@ const buildJS = async (entry, outfile) => {
|
|
|
237
239
|
supported: { "template-literal": false },
|
|
238
240
|
target: ["es2020"],
|
|
239
241
|
legalComments: "none",
|
|
242
|
+
...options
|
|
240
243
|
});
|
|
241
244
|
console.log(`✅ JS generated: ${outfile}`);
|
|
242
245
|
} catch (err) {
|
|
@@ -255,4 +258,15 @@ const buildJS = async (entry, outfile) => {
|
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
|
|
258
|
-
|
|
261
|
+
const buildPHP = async (file) => {
|
|
262
|
+
const results = await pxpros.render(file);
|
|
263
|
+
if(results.success) {
|
|
264
|
+
results.files.forEach(file => console.log(`✅ HTML generated: ${file}`));
|
|
265
|
+
} else {
|
|
266
|
+
console.error("❌ pxpros render failed.");
|
|
267
|
+
console.error(results.error);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
module.exports = { createWatchers, buildCSS, buildJS, buildPHP };
|