From ce977ae830726feeaeb915ece81750ddb524737f Mon Sep 17 00:00:00 2001 From: elmohmoh Date: Sat, 18 Dec 2021 16:12:06 +0100 Subject: [PATCH] Fix Error: Cannot find module ../lib\MjBasicComponent.js --- .mjmlconfig | 6 +++--- gulpfile.babel.js | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.mjmlconfig b/.mjmlconfig index d6d1a4c..3f7a529 100644 --- a/.mjmlconfig +++ b/.mjmlconfig @@ -1,7 +1,7 @@ { "packages": [ - "./lib/MjBasicComponent.js", - "./lib/MjImageText.js", - "./lib/MjLayout.js" + "./lib/compponents/MjBasicComponent.js", + "./lib/compponents/MjImageText.js", + "./lib/compponents/MjLayout.js" ] } diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 6d96588..66d0f46 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -8,7 +8,7 @@ import mjml2html from 'mjml' import { registerComponent } from 'mjml-core' const walkSync = (dir, filelist = []) => { - fs.readdirSync(dir).forEach(file => { + fs.readdirSync(dir).forEach((file) => { filelist = fs.statSync(path.join(dir, file)).isDirectory() ? walkSync(path.join(dir, file), filelist) : filelist.concat(path.join(dir, file)) @@ -21,14 +21,16 @@ const watchedComponents = walkSync('./components') const compile = () => { return gulp .src(path.normalize('components/**/*.js')) - .pipe(babel({ - presets: ['@babel/preset-env'], - })) + .pipe( + babel({ + presets: ['@babel/preset-env'], + }), + ) .on('error', log) .pipe(gulp.dest('lib')) .on('end', () => { - watchedComponents.forEach(compPath => { - const fullPath = path.join(process.cwd(), compPath.replace(/^components/, 'lib')) + watchedComponents.forEach((compPath) => { + const fullPath = path.join(process.cwd(), compPath.replace('/^components/', 'lib')) delete require.cache[fullPath] registerComponent(require(fullPath).default) })