From 531f72d66d91de14b08d026380c0d756b90597d9 Mon Sep 17 00:00:00 2001 From: Saeid Mohadjer Date: Sat, 21 Oct 2023 09:02:23 +0200 Subject: [PATCH] updates copy.js --- CHANGELOG.md | 4 ++++ bin/copy.js | 18 +++++++++++++++++- package.json | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01c5a8d..62ce172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.5 + +* Updated copy.js to allow copying .css files in 'resources/css' folder to public folder, except files in modules folder which get bundled into styles.css. + ## 2.0.3 * Adds target property to esbuild to allow use of nesting in css files diff --git a/bin/copy.js b/bin/copy.js index b1f3ca1..65b489e 100644 --- a/bin/copy.js +++ b/bin/copy.js @@ -25,7 +25,6 @@ function copyResources(folder) { const destDir = './public/resources/' + folder; if (folder === 'js') { - //compile typescript files traverseDir(srcDir, (filePath) => { console.log('js: ', filePath); const extension = path.extname(filePath); @@ -43,6 +42,22 @@ function copyResources(folder) { }); } }); + } else if (folder === 'css') { + traverseDir(srcDir, (filePath) => { + // css files inside modules get bundled into styles.css, so no need to copy them + if (filePath.indexOf('/modules') === -1 && + filePath.indexOf('styles.css') === -1 && + filePath.indexOf('.DS_Store') === -1) { + console.log('css: ', filePath); + const targetPath = filePath.replace('app/', 'public/'); + fse.copy(filePath, targetPath, function (err) { + if (err){ + return console.error(`Error while copying folder ${folder}`, err) + } + console.log(targetPath, ' copy completed!') + }); + } + }); } else { //https://stackoverflow.com/questions/13786160/copy-folder-recursively-in-node-js try { @@ -102,6 +117,7 @@ function copyRootFiles(source, target) { copyDependencies('css'); copyDependencies('js'); copyResources('js'); +copyResources('css'); copyRootFiles('app', 'public'); diff --git a/package.json b/package.json index 505f6f8..5105071 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "build", - "version": "2.0.4", + "version": "2.0.5", "description": "Frontend build for HTML websites", "type": "module", "repository": {