From ef8b65c98aa9024570290be3f6f9437085cd4c6f Mon Sep 17 00:00:00 2001 From: Reuben Son Date: Thu, 2 Sep 2021 10:52:18 -0400 Subject: [PATCH 1/2] hacky changes to allow easier vue plugin development in nymag/sites --- cli/compile/index.js | 6 +++--- lib/cmd/compile/scripts.js | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cli/compile/index.js b/cli/compile/index.js index 234421a9..dd0a9577 100644 --- a/cli/compile/index.js +++ b/cli/compile/index.js @@ -35,7 +35,7 @@ function handler(argv) { const t1 = Date.now(), media = compile.media({ watch: argv.watch }); // run media task before others (specifically, templates) - return h(media.build).collect().toArray((mediaResults) => { + return h([]).toArray((mediaResults) => { const fonts = compile.fonts({ watch: argv.watch, minify: argv.minify, @@ -57,9 +57,9 @@ function handler(argv) { globs: argv.globs, reporter: argv.reporter }), - tasks = [fonts, styles, templates, scripts], + tasks = [scripts], builders = _.map(tasks, (task) => task.build), - watchers = _.map(tasks, (task) => task.watch).concat([media.watch]), + watchers = _.map(tasks, (task) => task.watch), isWatching = !!watchers[0]; return h([h.of(mediaResults)].concat(builders)) diff --git a/lib/cmd/compile/scripts.js b/lib/cmd/compile/scripts.js index 42770866..48e14fb7 100644 --- a/lib/cmd/compile/scripts.js +++ b/lib/cmd/compile/scripts.js @@ -333,7 +333,8 @@ function buildScripts(entries, options = {}) { // speed up full rebuilds for developers if (!options.minify) { - browserifyCache(bundler, { cacheFile: browserifyCachePath }); + // something in this browserifyCache call seems to be breaking compilation of vue plugin assets + // browserifyCache(bundler, { cacheFile: browserifyCachePath }); // note: this file is NOT written in production environments } @@ -436,17 +437,18 @@ function buildScripts(entries, options = {}) { function compile(options = {}) { const watch = options.watch || false, minify = options.minify || variables.minify || false, - globs = options.globs || [], + // globs = options.globs || [], + globs = [], reporter = options.reporter || 'pretty', globFiles = globs.length ? _.flatten(_.map(globs, (g) => glob.sync(path.join(process.cwd(), g)))) : [], // client.js, model.js, kiln plugins, and legacy global scripts are passed to megabundler - bundleEntries = glob.sync(componentClientsGlob).concat( - glob.sync(componentModelsGlob), - glob.sync(componentKilnGlob), - glob.sync(layoutClientsGlob), - glob.sync(layoutModelsGlob), - glob.sync(kilnPluginsGlob), - globFiles + bundleEntries = glob.sync(kilnPluginsGlob).concat( + // glob.sync(componentModelsGlob), + // glob.sync(componentKilnGlob), + // glob.sync(layoutClientsGlob), + // glob.sync(layoutModelsGlob), + // glob.sync(kilnPluginsGlob) + // globFiles ), // options are set beforehand, so we can grab the cached files to watch afterwards bundleOptions = { minify, legacyFiles: globFiles }, @@ -482,7 +484,9 @@ function compile(options = {}) { * would be removed from this deps file upon watch recompilation. * @see https://github.com/clay/claycli/issues/116#issuecomment-454110714 */ - buildScripts(bundleOptions.cache.files, bundleOptions) + // limiting entrypoints to kiln directory files + let cacheFiles = bundleOptions.cache.files.filter(item => item.match(/\/kiln\//)); + buildScripts( cacheFiles, bundleOptions) .then(function (result) { _.map(result, reporters.logAction(reporter, 'compile')); }); From 57137ff9c719edd3ec8712188b37cd65bb98fa08 Mon Sep 17 00:00:00 2001 From: Reuben Son Date: Tue, 7 Sep 2021 12:45:33 -0400 Subject: [PATCH 2/2] tweak script assets --- lib/cmd/compile/scripts.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/cmd/compile/scripts.js b/lib/cmd/compile/scripts.js index 48e14fb7..01db4d89 100644 --- a/lib/cmd/compile/scripts.js +++ b/lib/cmd/compile/scripts.js @@ -443,11 +443,11 @@ function compile(options = {}) { globFiles = globs.length ? _.flatten(_.map(globs, (g) => glob.sync(path.join(process.cwd(), g)))) : [], // client.js, model.js, kiln plugins, and legacy global scripts are passed to megabundler bundleEntries = glob.sync(kilnPluginsGlob).concat( - // glob.sync(componentModelsGlob), - // glob.sync(componentKilnGlob), - // glob.sync(layoutClientsGlob), + glob.sync(componentModelsGlob), + glob.sync(componentKilnGlob), + glob.sync(layoutClientsGlob), // glob.sync(layoutModelsGlob), - // glob.sync(kilnPluginsGlob) + // glob.sync(kilnPluginsGlob), // globFiles ), // options are set beforehand, so we can grab the cached files to watch afterwards @@ -492,6 +492,8 @@ function compile(options = {}) { }); // and re-copy the _client-init.js if it has changed copyClientInit(); + + console.log('Recompilation in progress ...'); } }); }