move-nuxt-module
Advanced tools
Comparing version 1.2.1 to 1.3.0
44
index.js
@@ -6,26 +6,24 @@ const path = require("path"); | ||
async function asyncModule() { | ||
const { outputDir, dirName, version, type } = this.options.moveModuleOptions; | ||
const { buildEnv } = this.options.global; | ||
if (buildEnv === "prod" || buildEnv === "release") { | ||
this.nuxt.hook("generate:done", async nuxt => { | ||
const dir = path.join(nuxt.options.rootDir, "dist", outputDir); | ||
let entriePath = ""; | ||
if (type === "oss") { | ||
entriePath = path.join(dir, "assets", dirName, version, "**/*.html"); | ||
} else if(type === "server") { | ||
entriePath = path.join(dir, dirName, version, "**/*.html"); | ||
}else{ | ||
entriePath = path.join(dir, "assets", dirName, version, "**/*.html"); | ||
} | ||
const { outputDir, dirName, version, type } = this.options.globalModuleOptions; | ||
const moveDir = path.join(dir, dirName); | ||
vfs.src(entriePath).pipe(vfs.dest(moveDir)); | ||
vfs.src(entriePath).pipe( | ||
map(function(file, cb) { | ||
fse.removeSync(file.path); | ||
cb(null, file); | ||
}) | ||
); | ||
}); | ||
} | ||
this.nuxt.hook("generate:done", async nuxt => { | ||
const dir = path.join(nuxt.options.rootDir, "dist", outputDir); | ||
let entriePath = ""; | ||
if (type === "oss") { | ||
entriePath = path.join(dir, "assets", dirName, version, "**/*.html"); | ||
} else if (type === "server") { | ||
entriePath = path.join(dir, dirName, version, "**/*.html"); | ||
} else { | ||
entriePath = path.join(dir, "assets", dirName, version, "**/*.html"); | ||
} | ||
const moveDir = path.join(dir, dirName); | ||
vfs.src(entriePath).pipe(vfs.dest(moveDir)); | ||
vfs.src(entriePath).pipe( | ||
map(function(file, cb) { | ||
fse.removeSync(file.path); | ||
cb(null, file); | ||
}) | ||
); | ||
}); | ||
} | ||
@@ -32,0 +30,0 @@ |
{ | ||
"name": "move-nuxt-module", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
1186
28