From a3799d090070e11a73a6b04ab006cdef237cf74a Mon Sep 17 00:00:00 2001 From: Jack Works Date: Sun, 28 Apr 2019 20:18:27 +0800 Subject: [PATCH] Move polyfills out. (Partly) Test with Firefox #25 --- .gitignore | 1 + config-overrides.js | 13 ++++++++++--- public/index.html | 2 ++ public/manifest.json | 18 +++++++++--------- src/extension/content-script/index.tsx | 3 --- .../content-script/injections/LiveSelectors.ts | 4 +++- .../content-script/injections/Posts.tsx | 8 ++++++-- src/extension/service.ts | 4 ++-- src/setup.ts | 4 ---- 9 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index dd73fe94f26f..f64579b94720 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. /.awcache /.tscache +public/polyfill # dependencies /node_modules /.pnp diff --git a/config-overrides.js b/config-overrides.js index 4e01b86b315f..f1ebc60a08c0 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -11,8 +11,8 @@ module.exports = function override(/** @type{import("webpack").Configuration} */ backgroundservice: path.join(__dirname, './src/background-service.ts'), injectedscript: path.join(__dirname, './src/extension/injected-script/index.ts'), } - config.output.filename = 'static/js/[name].js' - config.output.chunkFilename = 'static/js/[name].chunk.js' + config.output.filename = 'js/[name].js' + config.output.chunkFilename = 'js/[name].chunk.js' // No split config.optimization.runtimeChunk = false @@ -25,13 +25,20 @@ module.exports = function override(/** @type{import("webpack").Configuration} */ config.plugins.push( new (require('write-file-webpack-plugin'))({ - test: /(static\/.*|.+\.png|index\.html|manifest\.json)/, + test: /(shim|polyfill|js\/.*|.+\.png|index\.html|manifest\.json)/, }), ) // Write files to /public + const polyfills = [ + 'node_modules/construct-style-sheets-polyfill/adoptedStyleSheets.min.js', + 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js', + 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js.map', + 'node_modules/webcrypto-liner/dist/webcrypto-liner.shim.js', + ].map(x => ({ from: x, to: path.join(__dirname, './public/polyfill/') })) config.plugins.push( new (require('copy-webpack-plugin'))( [ + ...polyfills, { from: path.join(__dirname, './public'), to: path.join(__dirname, './dist'), diff --git a/public/index.html b/public/index.html index 3f2e0045a972..65b7f0989d5e 100644 --- a/public/index.html +++ b/public/index.html @@ -1,6 +1,8 @@ + +