From a4a4e1a3347be974ac9b8d2516857723580050c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 20 Sep 2024 09:24:08 +0200 Subject: [PATCH] Add missing CSS in dist folder --- buildtools/webpack.commons.js | 9 ++- buildtools/webpack.dist.js | 26 ++++++-- buildtools/webpack.prod.js | 2 +- package-lock.json | 110 +++++++++++++++++++++++++++++++++- package.json | 2 +- 5 files changed, 138 insertions(+), 11 deletions(-) diff --git a/buildtools/webpack.commons.js b/buildtools/webpack.commons.js index 90a625733447..d9f656e5d710 100644 --- a/buildtools/webpack.commons.js +++ b/buildtools/webpack.commons.js @@ -21,7 +21,7 @@ const path = require('path'); const webpack = require('webpack'); -const {PromiseTask} = require('event-hooks-webpack-plugin/lib/tasks'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const devMode = process.env.NODE_ENV !== 'production'; @@ -85,13 +85,13 @@ module.exports = function (config) { rules.push({ test: /\.css$/, - use: [{loader: 'style-loader'}, {loader: 'css-loader'}], + use: [{loader: MiniCssExtractPlugin.loader}, {loader: 'css-loader'}], }); rules.push({ test: /\.s[ac]ss$/i, use: [ - {loader: 'style-loader'}, + {loader: MiniCssExtractPlugin.loader}, {loader: 'css-loader'}, {loader: 'sass-loader', options: {warnRuleAsWarning: false}}, ], @@ -141,6 +141,9 @@ module.exports = function (config) { resourceRegExp: /^\.\/locale$/, contextRegExp: /node_modules\/moment\/src\/lib\/locale$/, }), + new MiniCssExtractPlugin({ + filename: '[name]-[contenthash:6].css', + }), ]; if (config.nodll != true) { plugins.push(dllPlugin); diff --git a/buildtools/webpack.dist.js b/buildtools/webpack.dist.js index 5e4f31419f91..d50a00994941 100644 --- a/buildtools/webpack.dist.js +++ b/buildtools/webpack.dist.js @@ -19,10 +19,26 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +const plugins = []; +const entry = {}; + +for (const name of ['desktop', 'mobile', 'iframe_api']) { + const folder = `contribs/gmf/apps/${name}`; + entry[name] = `./${folder}/Controller.js`; + plugins.push( + new HtmlWebpackPlugin({ + template: `${folder}/index.html.ejs`, + inject: false, + filename: `${name}.html`, + chunks: [name], + }), + ); +} + module.exports = { - entry: { - desktop: './contribs/gmf/apps/desktop_alt/Controller.js', - mobile: './contribs/gmf/apps/mobile_alt/Controller.js', - iframe_api: './contribs/gmf/apps/iframe_api/Controller.js', - }, + entry: entry, + plugins: plugins, }; diff --git a/buildtools/webpack.prod.js b/buildtools/webpack.prod.js index e10c120ab1a9..e2cfd2224ece 100644 --- a/buildtools/webpack.prod.js +++ b/buildtools/webpack.prod.js @@ -27,7 +27,7 @@ module.exports = function () { mode: 'production', devtool: 'source-map', output: { - filename: '[name].[chunkhash:6].js', + filename: '[name]-[chunkhash:6].js', assetModuleFilename: '[name]-[contenthash:6][ext]', }, plugins: [new webpack.optimize.ModuleConcatenationPlugin()], diff --git a/package-lock.json b/package-lock.json index 657a78224fc9..13b4d3280a3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -100,6 +100,7 @@ "chromatic": "11.7.1", "commander": "12.1.0", "copy-webpack-plugin": "12.0.2", + "copyfiles": "2.4.1", "css-loader": "7.1.2", "cy-mobile-commands": "0.3.0", "cypress": "13.14.1", @@ -131,6 +132,7 @@ "karma-webpack": "5.0.1", "loader-utils": "3.3.1", "magic-comments-loader": "2.1.3", + "mini-css-extract-plugin": "2.9.1", "minify-html-literals-loader": "1.1.1", "neat-csv": "6.0.1", "parse-absolute-css-unit": "1.0.2", @@ -142,7 +144,6 @@ "start-server-and-test": "2.0.5", "storybook": "8.2.9", "strip-bom": "5.0.0", - "style-loader": "4.0.0", "svgo": "3.3.2", "svgo-loader": "4.0.0", "terser": "5.31.6", @@ -9713,6 +9714,58 @@ "node": ">=10.13.0" } }, + "node_modules/copyfiles": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/copyfiles/-/copyfiles-2.4.1.tgz", + "integrity": "sha512-fereAvAvxDrQDOXybk3Qu3dPbOoKoysFMWtkY3mv5BsL8//OSZVL5DCLYqgRfY5cWirgRzlC+WSrxp6Bo3eNZg==", + "dev": true, + "dependencies": { + "glob": "^7.0.5", + "minimatch": "^3.0.3", + "mkdirp": "^1.0.4", + "noms": "0.0.0", + "through2": "^2.0.1", + "untildify": "^4.0.0", + "yargs": "^16.1.0" + }, + "bin": { + "copyfiles": "copyfiles", + "copyup": "copyfiles" + } + }, + "node_modules/copyfiles/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/copyfiles/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/core-js-compat": { "version": "3.38.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", @@ -16320,6 +16373,26 @@ "node": ">=4" } }, + "node_modules/mini-css-extract-plugin": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-2.9.1.tgz", + "integrity": "sha512-+Vyi+GCCOHnrJ2VPS+6aPoXN2k2jgUzDRhTFLjjTBn23qyXJXkjUWQgTL+mXpF5/A8ixLdCc6kWsoeOjKGejKQ==", + "dev": true, + "dependencies": { + "schema-utils": "^4.0.0", + "tapable": "^2.2.1" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.0.0" + } + }, "node_modules/minify-html-literals": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/minify-html-literals/-/minify-html-literals-1.3.5.tgz", @@ -16685,6 +16758,40 @@ "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "dev": true }, + "node_modules/noms": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/noms/-/noms-0.0.0.tgz", + "integrity": "sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "~1.0.31" + } + }, + "node_modules/noms/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true + }, + "node_modules/noms/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/noms/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "dev": true + }, "node_modules/nopt": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", @@ -20559,6 +20666,7 @@ "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-4.0.0.tgz", "integrity": "sha512-1V4WqhhZZgjVAVJyt7TdDPZoPBPNHbekX4fWnCJL1yQukhCeZhJySUL+gL9y6sNdN95uEOS83Y55SqHcP7MzLA==", "dev": true, + "peer": true, "engines": { "node": ">= 18.12.0" }, diff --git a/package.json b/package.json index 64acad802dbf..13c7433ac736 100644 --- a/package.json +++ b/package.json @@ -187,6 +187,7 @@ "karma-webpack": "5.0.1", "loader-utils": "3.3.1", "magic-comments-loader": "2.1.3", + "mini-css-extract-plugin": "2.9.1", "minify-html-literals-loader": "1.1.1", "neat-csv": "6.0.1", "parse-absolute-css-unit": "1.0.2", @@ -198,7 +199,6 @@ "start-server-and-test": "2.0.5", "storybook": "8.2.9", "strip-bom": "5.0.0", - "style-loader": "4.0.0", "svgo": "3.3.2", "svgo-loader": "4.0.0", "terser": "5.31.6",