Last active
July 20, 2020 19:40
Revisions
-
moose56 revised this gist
Jul 20, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,9 +20,9 @@ const del = require('del'); console.log('addAsset', asset.toString()); }); await graph.loadAssets('*.html'); // load assets for all html files await graph.populate(); // populate the graph with the assets await hashFiles(graph); // hash the appropriate assets await graph.writeAssetsToDisc({isLoaded: true}, './dist'); // save all to the dist folder })(); -
moose56 created this gist
Jul 20, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ const AssetGraph = require('assetgraph'); // library to build dependency tree const hashFiles = require('assetgraph-hashfiles'); // library to add hash const del = require('del'); // top level await calls need to be inside // an async function call (async () => { // remove old version of dist folder so // we start from a clean slate and no old // versions are left around const deletedPaths = await del(['./dist']); deletedPaths.forEach(p => console.log(`deleted path: ${p}`)); // create new graph of the public folder const graph = new AssetGraph({root: './public'}); // output events for logging graph.on('addAsset', function (asset) { console.log('addAsset', asset.toString()); }); await graph.loadAssets('*.html'); // load assests for all html files await graph.populate(); // populate the graph with the assests await hashFiles(graph); // hash the appropriate assests await graph.writeAssetsToDisc({isLoaded: true}, './dist'); // save all to the dist folder })();