Skip to content

Commit

Permalink
updates copy.js
Browse files Browse the repository at this point in the history
  • Loading branch information
smohadjer committed Oct 21, 2023
1 parent 343ca06 commit 531f72d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 17 additions & 1 deletion bin/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -102,6 +117,7 @@ function copyRootFiles(source, target) {
copyDependencies('css');
copyDependencies('js');
copyResources('js');
copyResources('css');

copyRootFiles('app', 'public');

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build",
"version": "2.0.4",
"version": "2.0.5",
"description": "Frontend build for HTML websites",
"type": "module",
"repository": {
Expand Down

0 comments on commit 531f72d

Please sign in to comment.