diff --git a/package-lock.json b/package-lock.json index 3930350..5b8d338 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9091,9 +9091,8 @@ } }, "csp-html-webpack-plugin": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/csp-html-webpack-plugin/-/csp-html-webpack-plugin-5.1.0.tgz", - "integrity": "sha512-6l/s6hACE+UA01PLReNKZfgLZWM98f7ewWmE79maDWIbEXiPcIWQGB3LQR/Zw+hPBj4XPZZ5zNrrO+aygqaLaQ==", + "version": "github:sersorrel/csp-html-webpack-plugin#ee19fd58bb8cd3da367c902a0293f2f11c1aae1f", + "from": "github:sersorrel/csp-html-webpack-plugin#hash-external-scripts", "dev": true, "requires": { "cheerio": "^1.0.0-rc.5", @@ -11988,6 +11987,15 @@ "integrity": "sha512-8nxjcBcd8wovbeKx7h3wTji4e6+rhaVuPNpMqwWgnHh+N9ToqsCs6XztWRBPQ+UtzsoMAdKZtUENoVzU/EMtZA==", "dev": true }, + "html-inline-css-webpack-plugin": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/html-inline-css-webpack-plugin/-/html-inline-css-webpack-plugin-1.10.1.tgz", + "integrity": "sha512-VRNQ8G4bSooqtVoQ7eQbaeEeaw4cmVvI3jxO7WhCEKZb5rtrCFHzX0W18rImaA8Jb+pg20BqgpkNGuBVRElFfw==", + "dev": true, + "requires": { + "lodash": "^4.17.15" + } + }, "html-minifier-terser": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz", @@ -13260,6 +13268,50 @@ "dom-walk": "^0.1.0" } }, + "mini-css-extract-plugin": { + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-1.3.9.tgz", + "integrity": "sha512-Ac4s+xhVbqlyhXS5J/Vh/QXUz3ycXlCqoCPpg0vdfhsIBH9eg/It/9L1r1XhSCH737M1lqcWnMuWL13zcygn5A==", + "dev": true, + "requires": { + "loader-utils": "^2.0.0", + "schema-utils": "^3.0.0", + "webpack-sources": "^1.1.0" + }, + "dependencies": { + "json5": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "schema-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz", + "integrity": "sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.6", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + } + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", diff --git a/package.json b/package.json index a1ea3ac..7736f43 100644 --- a/package.json +++ b/package.json @@ -80,13 +80,15 @@ "@types/react-dom": "^17.0.2", "@typescript-eslint/eslint-plugin": "^4.17.0", "@typescript-eslint/parser": "^4.17.0", - "csp-html-webpack-plugin": "^5.1.0", + "csp-html-webpack-plugin": "github:sersorrel/csp-html-webpack-plugin#hash-external-scripts", "css-loader": "^4.3.0", "electron": "12.0.1", "electron-devtools-installer": "^3.1.1", "eslint": "^7.22.0", "eslint-plugin-import": "^2.22.1", "fork-ts-checker-webpack-plugin": "^5.2.1", + "html-inline-css-webpack-plugin": "^1.10.1", + "mini-css-extract-plugin": "^1.3.9", "node-loader": "^1.0.2", "style-loader": "^1.3.0", "ts-loader": "^8.0.18", diff --git a/webpack.plugins.js b/webpack.plugins.js index 3f60b0e..af2d7d4 100644 --- a/webpack.plugins.js +++ b/webpack.plugins.js @@ -1,11 +1,15 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const HtmlInlineCssWebpackPlugin = require('html-inline-css-webpack-plugin').default; const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin'); module.exports = [ new ForkTsCheckerWebpackPlugin(), + new MiniCssExtractPlugin(), + new HtmlInlineCssWebpackPlugin(), new CspHtmlWebpackPlugin({ 'script-src': "'self'", - 'style-src': "'self' 'unsafe-inline'", + 'style-src': "", }, { nonceEnabled: { 'script-src': false, diff --git a/webpack.renderer.config.js b/webpack.renderer.config.js index fee66bd..728ef9d 100644 --- a/webpack.renderer.config.js +++ b/webpack.renderer.config.js @@ -1,9 +1,11 @@ +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); + const rules = require('./webpack.rules'); const plugins = require('./webpack.plugins'); rules.push({ test: /\.css$/, - use: [{ loader: 'style-loader' }, { loader: 'css-loader' }], + use: [{ loader: MiniCssExtractPlugin.loader }, { loader: 'css-loader' }], }); module.exports = {