diff --git a/manifest.js b/manifest.js new file mode 100644 index 0000000..785dfaf --- /dev/null +++ b/manifest.js @@ -0,0 +1,11 @@ +const fs = require("fs"); +const manifest = require("./src/manifest.json"); + +manifest.h5.publicPath = process.env.SERVER_ENV !== "NETLIFY" ? "/md/" : "/"; +const result = JSON.stringify(manifest, null, 2); + +fs.writeFile("./src/manifest.json", result, function (err) { + if (err) { + console.error(err); + } +}); diff --git a/package.json b/package.json index f99df04..2a996ac 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "version": "1.5.0", "private": true, "scripts": { - "serve": "npm run dev:h5", - "build": "npm run build:h5", + "serve": "node manifest.js & npm run dev:h5", + "build": "node manifest.js & npm run build:h5", + "build:h5-netlify": "cross-env SERVER_ENV=NETLIFY node manifest.js & npm run build:h5", "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build", "build:custom": "cross-env NODE_ENV=production uniapp-cli custom", "build:h5": "cross-env NODE_ENV=production UNI_OUTPUT_DIR=dist UNI_PLATFORM=h5 vue-cli-service uni-build", - "build:h5-netlify": "cross-env NODE_ENV=production SERVER_ENV=NETLIFY UNI_OUTPUT_DIR=dist UNI_PLATFORM=h5 vue-cli-service uni-build", "build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build", "build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build", "build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build", diff --git a/vue.config.js b/vue.config.js deleted file mode 100644 index 21ee4ac..0000000 --- a/vue.config.js +++ /dev/null @@ -1,19 +0,0 @@ -const fs = require("fs"); -function writeManifestJson() { - fs.readFile("./src/manifest.json", function (err, data) { - if (err) { - return console.error(err); - } - const strData = data.toString(); - const manifest = JSON.parse(strData); - - manifest.h5.publicPath = process.env.SERVER_ENV !== "NETLIFY" ? "/md/" : "/"; - const result = JSON.stringify(manifest, null, 2); - - fs.writeFile("./src/manifest.json", result, function (err) { - if (err) { - console.error(err); - } - }); - }); -}