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',