Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy *all* assets files #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ const fs = require('fs-extra');
const os = require('os');

/**
* Hooks!
*
* Hooks!
*
* Lifecycle hooks are the backbone of how you can have complete control over the output of your site.
* Hooks are enforced via the hookInterface 'contract' defined here:
* Hooks are enforced via the hookInterface 'contract' defined here:
https://github.com/Elderjs/elderjs/blob/master/src/hookInterface/hookInterface.ts
*
* If you read the hookInterface spec closely you'll see that each defined hook gets specific 'props' along with which of those props is 'mutable'.
*
* If you're a fan of 'pure' functions in JS, mutating props will probably set off alarm bells in your head. Fear not, instead of burying
*
* If you're a fan of 'pure' functions in JS, mutating props will probably set off alarm bells in your head. Fear not, instead of burying
* what is mutating things deep in your application, you'll know it is probably in this file.
*
* Also, to help keep mutation predictable each 'hook' limits which 'props' can be manipulated and where.
*
* Also, to help keep mutation predictable each 'hook' limits which 'props' can be manipulated and where.
*
*/

const hooks = [
Expand Down Expand Up @@ -47,14 +47,10 @@ const hooks = [

// copy assets folder to public destination
glob.sync(path.resolve(settings.rootDir, './assets/**/*')).forEach((file) => {
const parsed = path.parse(file);
// Only write the file/folder structure if it has an extension
if (parsed.ext && parsed.ext.length > 0) {
const relativeToAssetsFolder = path.relative(path.join(settings.rootDir, './assets'), file);
const outputPath = path.resolve(settings.distDir, relativeToAssetsFolder);
fs.ensureDirSync(path.parse(outputPath).dir);
fs.outputFileSync(outputPath, fs.readFileSync(file));
}
const relativeToAssetsFolder = path.relative(path.join(settings.rootDir, './assets'), file);
const outputPath = path.resolve(settings.distDir, relativeToAssetsFolder);
fs.ensureDirSync(path.parse(outputPath).dir);
fs.outputFileSync(outputPath, fs.readFileSync(file));
});
},
},
Expand Down