diff --git a/extension/gulpfile.babel.js b/extension/gulpfile.babel.js index 11205deb..7732c595 100644 --- a/extension/gulpfile.babel.js +++ b/extension/gulpfile.babel.js @@ -15,26 +15,6 @@ function copy(dest) { gulp.src('./src/assets/**/*').pipe(gulp.dest(dest)); } -/* - * common tasks - */ -gulp.task('replace-webpack-code', (done) => { - const replaceTasks = [ - { - from: './webpack/replace/JsonpMainTemplate.runtime.js', - to: './node_modules/webpack/lib/JsonpMainTemplate.runtime.js', - }, - { - from: './webpack/replace/log-apply-result.js', - to: './node_modules/webpack/hot/log-apply-result.js', - }, - ]; - replaceTasks.forEach((task) => - fs.writeFileSync(task.to, fs.readFileSync(task.from)) - ); - done(); -}); - /* * dev tasks */ @@ -173,7 +153,6 @@ gulp.task('test:electron', () => { gulp.task( 'default', gulp.parallel( - 'replace-webpack-code', 'webpack:dev', 'views:dev', 'copy:dev', @@ -184,7 +163,6 @@ gulp.task( gulp.task( 'build:extension', gulp.parallel( - 'replace-webpack-code', 'webpack:build:extension', 'views:build:extension', 'copy:build:extension' diff --git a/extension/webpack/replace/JsonpMainTemplate.runtime.js b/extension/webpack/replace/JsonpMainTemplate.runtime.js deleted file mode 100644 index 130094c0..00000000 --- a/extension/webpack/replace/JsonpMainTemplate.runtime.js +++ /dev/null @@ -1,76 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */ -module.exports = function () { - function webpackHotUpdateCallback(chunkId, moreModules) { - // eslint-disable-line no-unused-vars - hotAddUpdateChunk(chunkId, moreModules); - if (parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules); - } - - var context = this; - function evalCode(code, context) { - return function () { - return eval(code); - }.call(context); - } - - context.hotDownloadUpdateChunk = function (chunkId) { - // eslint-disable-line no-unused-vars - var src = - __webpack_require__.p + - '' + - chunkId + - '.' + - hotCurrentHash + - '.hot-update.js'; - var request = new XMLHttpRequest(); - - request.onload = function () { - evalCode(this.responseText, context); - }; - request.open('get', src, true); - request.send(); - }; - - function hotDownloadManifest(callback) { - // eslint-disable-line no-unused-vars - if (typeof XMLHttpRequest === 'undefined') - return callback(new Error('No browser support')); - try { - var request = new XMLHttpRequest(); - var requestPath = $require$.p + $hotMainFilename$; - request.open('GET', requestPath, true); - request.timeout = 10000; - request.send(null); - } catch (err) { - return callback(err); - } - request.onreadystatechange = function () { - if (request.readyState !== 4) return; - if (request.status === 0) { - // timeout - callback( - new Error('Manifest request to ' + requestPath + ' timed out.') - ); - } else if (request.status === 404) { - // no update available - callback(); - } else if (request.status !== 200 && request.status !== 304) { - // other failure - callback(new Error('Manifest request to ' + requestPath + ' failed.')); - } else { - // success - try { - var update = JSON.parse(request.responseText); - } catch (e) { - callback(e); - return; - } - callback(null, update); - } - }; - } -}; diff --git a/extension/webpack/replace/log-apply-result.js b/extension/webpack/replace/log-apply-result.js deleted file mode 100644 index bf379810..00000000 --- a/extension/webpack/replace/log-apply-result.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -module.exports = function (updatedModules, renewedModules) { - var unacceptedModules = updatedModules.filter(function (moduleId) { - return renewedModules && renewedModules.indexOf(moduleId) < 0; - }); - - if (unacceptedModules.length > 0) { - console.warn( - "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)" - ); - unacceptedModules.forEach(function (moduleId) { - console.warn('[HMR] - ' + moduleId); - }); - - if (chrome && chrome.runtime && chrome.runtime.reload) { - console.warn('[HMR] extension reload'); - chrome.runtime.reload(); - } else { - console.warn( - "[HMR] Can't extension reload. not found chrome.runtime.reload." - ); - } - } - - if (!renewedModules || renewedModules.length === 0) { - console.log('[HMR] Nothing hot updated.'); - } else { - console.log('[HMR] Updated modules:'); - renewedModules.forEach(function (moduleId) { - console.log('[HMR] - ' + moduleId); - }); - } -};