Skip to content

Commit 026abae

Browse files
author
Kyle Andrews
committed
Fixes compiler and updates readme
1 parent 2fb65a1 commit 026abae

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ npm run preview
3535
npm run deploy
3636
```
3737

38+
### Deploying to GitHub Pages
39+
40+
This project is set up to deploy to the gh-pages won push to the master branch. When deploying to gh-pages the project will need a secret named `ACCESS_TOKEN`. To generate a access token add a new [personal access token](https://github.com/settings/tokens) to your GitHub account with the "full control of private repositories" scope selected.
41+
42+
### Custom Domain
43+
44+
To set a custom domain for the project add a `CNAME` file to the projects root directory, the file will be bundled into the gh-pages deployment.
45+
3846
### Registering Files
3947

4048
Files are registered via script elements on the pages `.html` file. Use the following scripts to register your files.

compiler.config.js

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Compiler
1919
try
2020
{
2121
await this.removeAssetsDirectory();
22+
await this.createBuildDirectory();
2223
await this.createAssetsDirectory();
2324
await this.moveApplication();
2425
await this.moveWorker();
@@ -28,11 +29,11 @@ class Compiler
2829
const homepageHtmlFile = await this.getHomepageHtmlFile();
2930
await this.updateHomepageHtml(homepageHtmlFile, timestamp);
3031
await this.updateHtmlFiles(htmlFiles, timestamp)
31-
32+
3233
/** SASS */
3334
const sassFiles = await this.getSassFiles();
3435
await this.compileSass(sassFiles, timestamp);
35-
36+
3637
/** Web Components */
3738
const componentFiles = await this.getComponentFiles();
3839
await this.moveComponents(componentFiles, timestamp);
@@ -43,7 +44,7 @@ class Compiler
4344
const dependencies = await this.getWebDependencies();
4445
const serverSafeBundleNames = await this.writeBundles(dependencies);
4546
await this.buildPackages(serverSafeBundleNames, timestamp);
46-
47+
4748
await this.moveCNAME();
4849
}
4950
catch (error)
@@ -76,6 +77,12 @@ class Compiler
7677
{
7778
const built = [];
7879
return new Promise((resolve, reject)=>{
80+
81+
if (serverSafeBundleNames.length === 0)
82+
{
83+
resolve();
84+
}
85+
7986
for (let i = 0; i < serverSafeBundleNames.length; i++)
8087
{
8188
const inputOptions = {
@@ -135,6 +142,11 @@ class Compiler
135142
return new Promise((resolve, reject)=>{
136143

137144
const writtenBundles = [];
145+
146+
if (dependencies.length === 0)
147+
{
148+
resolve(writtenBundles);
149+
}
138150

139151
for (let i = 0; i < dependencies.length; i++)
140152
{
@@ -238,6 +250,11 @@ class Compiler
238250
return new Promise((resolve, reject)=>{
239251
let moved = 0;
240252

253+
if (files.length === 0)
254+
{
255+
resolve();
256+
}
257+
241258
for (let i = 0; i < files.length; i++)
242259
{
243260
const filename = files[i].replace(/.*\//g, '');
@@ -512,15 +529,39 @@ class Compiler
512529
});
513530
}
514531

515-
removeAssetsDirectory()
532+
createBuildDirectory()
516533
{
517534
return new Promise((resolve, reject)=>{
518-
fs.rmdir('build/assets', { recursive: true }, (error)=>{
519-
if (error)
520-
{
521-
reject(error);
522-
}
535+
fs.promises.access('build')
536+
.then(() => { resolve(); })
537+
.catch(() => {
538+
fs.mkdir('build', (error)=>{
539+
if (error)
540+
{
541+
reject(error);
542+
}
543+
544+
resolve();
545+
});
546+
});
547+
});
548+
}
523549

550+
removeAssetsDirectory()
551+
{
552+
return new Promise((resolve, reject)=>{
553+
fs.promises.access('build/assets')
554+
.then(() => {
555+
fs.rmdir('build/assets', { recursive: true }, (error)=>{
556+
if (error)
557+
{
558+
reject(error);
559+
}
560+
561+
resolve();
562+
});
563+
})
564+
.catch(() => {
524565
resolve();
525566
});
526567
});

0 commit comments

Comments
 (0)