From d1076660111ea3059147600f4b3bd3675ea27e9d Mon Sep 17 00:00:00 2001 From: "Manu [tennox]" <2084639+tennox@users.noreply.github.com> Date: Mon, 7 Nov 2022 17:29:25 +0000 Subject: [PATCH] Refactor imageBase to assetBaseUrl --- README.md | 4 ++-- config.js | 2 +- gulpfile.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 408fe85..77e1ef2 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ __`--out`__: Replaces the default output directory (`./output`) with the one pro A `config.js` file exists to provide configuration parameters for the build. The following attribute is supported: - - **`imageBase`**: The absolute URL where images are to be accessible publicly. + - **`assetBaseUrl`**: The absolute URL where images are to be accessible publicly. ## About images @@ -71,7 +71,7 @@ This would refer to an image stored in the following directory: `src/assets/logo It is not part of the scope of this tool to sync or upload images to a public hosting environment. All the tool does is repatriate every image file under the `src/assets` directory into the `output/assets` directory when building the project. Those files should then be uploaded/synced to a Web server serving static files. -When building templates for production (see _Building for production_ below), the `$IMGBASE$` variables will be replaced by the `imageBase` configuration attribute in `config.js`. +When building templates for production (see _Building for production_ below), the `$IMGBASE$` variables will be replaced by the `assetBaseUrl` configuration attribute in `config.js`. ## About translations / i18n diff --git a/config.js b/config.js index 77d2df8..2c86b2e 100644 --- a/config.js +++ b/config.js @@ -1,4 +1,4 @@ module.exports = { // This is where your images are to be hosted publicly - e.g. 'https://domain.org/images' - imageBase: process.env.EMAIL_ASSET_URL, + assetBaseUrl: process.env.EMAIL_ASSET_URL, }; diff --git a/gulpfile.js b/gulpfile.js index 52842f8..71e31d9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,9 +16,9 @@ const production = environments.production; const mjmlEngine = require('mjml'); -let imageBase = production() ? config.imageBase : './assets'; -if (!imageBase) throw new Error(`Empty imageBase in config.js`) -if (imageBase.endsWith('/')) imageBase = imageBase.replace(/\/$/, "") // remove trailing slash +let assetBaseUrl = production() ? config.assetBaseUrl : './assets'; +if (!assetBaseUrl) throw new Error(`Empty assetBaseUrl in config.js`) +if (assetBaseUrl.endsWith('/')) assetBaseUrl = assetBaseUrl.replace(/\/$/, "") // remove trailing slash const argOutput = argv.out || './output'; @@ -52,7 +52,7 @@ gulp.task('copy:assets', function () { gulp.task('build:html', function () { return gulp.src(files.templates) .pipe(nunjucks.compile({ - assetBaseUrl: imageBase + assetBaseUrl }, { searchPath: dirs.templates })) .pipe(mjml(mjmlEngine, { minify: false,