From e59f15064706288a5c8e39c12ccc4f46b9d94b91 Mon Sep 17 00:00:00 2001 From: theajack <1506282385@qq.com> Date: Sun, 24 Jan 2021 15:43:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20doc=20=E4=BD=BF=E7=94=A8=E6=9C=80?= =?UTF-8?q?=E6=96=B0cdn=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/mod-index-html-version.js | 13 +++++++++++++ index.html | 2 +- package.json | 3 ++- webpack-config/build.js | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 helper/mod-index-html-version.js diff --git a/helper/mod-index-html-version.js b/helper/mod-index-html-version.js new file mode 100644 index 0000000..9e72847 --- /dev/null +++ b/helper/mod-index-html-version.js @@ -0,0 +1,13 @@ +const pkg = require('../package.json'); +const util = require('./util'); + +function modIndexHtmlVersion () { + util.read('index.html', (html) => { + let res = html.match(new RegExp(`https://cdn.jsdelivr.net/npm/disable-devtool@.*/disable-devtool.min.js#use`)); + if (res) { + util.write('index.html', html.replace(res[0], `https://cdn.jsdelivr.net/npm/disable-devtool@${pkg.version}/disable-devtool.min.js#use`)); + } + }); +} + +modIndexHtmlVersion(); \ No newline at end of file diff --git a/index.html b/index.html index 2f594de..a21b160 100644 --- a/index.html +++ b/index.html @@ -178,7 +178,7 @@ disableDevtool(options);

diff --git a/package.json b/package.json index 34693f4..4dcc3fb 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "start": "npm run dev", "build": "webpack --config webpack-config/build.js", "publish": "npm publish npm", - "lint": "eslint src --ext js" + "lint": "eslint src --ext js", + "sync-version": "node helper/mod-index-html-version.js" }, "author": "theajack", "repository": { diff --git a/webpack-config/build.js b/webpack-config/build.js index b488424..b6ed829 100644 --- a/webpack-config/build.js +++ b/webpack-config/build.js @@ -1,6 +1,7 @@ const path = require('path'); require('../helper/copy-to-npm'); require('../helper/copy-version'); +require('../helper/mod-index-html-version'); module.exports = { mode: 'production',