diff --git a/app/frontend/src/stylesheets/app.functions.scss b/app/frontend/src/stylesheets/app.functions.scss index 44bc93ce1..6153ec37f 100644 --- a/app/frontend/src/stylesheets/app.functions.scss +++ b/app/frontend/src/stylesheets/app.functions.scss @@ -1,3 +1,5 @@ +@use "sass:math"; + // This is the default html and body font-size for the base rem value. $rem-base: 10px !default; @@ -20,12 +22,12 @@ $modules: () !default; // STRIP UNIT // It strips the unit of measure and returns it @function strip-unit($num) { - @return $num / ($num * 0 + 1); + @return math.div($num, $num * 0 + 1); } // CONVERT TO REM @function convert-to-rem($value, $base-value: $rem-base) { - $value: strip-unit($value) / strip-unit($base-value) * 1rem; + $value: math.div(strip-unit($value), strip-unit($base-value)) * 1rem; @if $value == 0rem { $value: 0; diff --git a/babel.config.js b/babel.config.js index 7c7062604..3157cfe20 100644 --- a/babel.config.js +++ b/babel.config.js @@ -21,33 +21,15 @@ module.exports = function (api) { const changesOnDefault = { presets: [ isTestEnv && [ - '@babel/preset-env', - { - targets: { - node: 'current' - }, - modules: 'commonjs' - }, '@babel/preset-react' ], (isProductionEnv || isDevelopmentEnv) && [ - '@babel/preset-env', - { - forceAllTransforms: true, - useBuiltIns: 'entry', - corejs: 3, - modules: false, - exclude: ['transform-typeof-symbol'] - } - ], - [ '@babel/preset-react', { development: isDevelopmentEnv || isTestEnv, useBuiltIns: true } - ], - ['@babel/preset-typescript', { allExtensions: true, isTSX: true }] + ] ].filter(Boolean), plugins: [ 'babel-plugin-macros', @@ -57,7 +39,7 @@ module.exports = function (api) { [ '@babel/plugin-proposal-class-properties', { - loose: false + loose: true } ], [ @@ -66,14 +48,6 @@ module.exports = function (api) { useBuiltIns: true } ], - [ - '@babel/plugin-transform-runtime', - { - helpers: false, - regenerator: true, - corejs: false - } - ], [ '@babel/plugin-transform-regenerator', { diff --git a/config/webpack/loaders/sass.js b/config/webpack/loaders/sass.js index 297c01630..9fb59d0ef 100644 --- a/config/webpack/loaders/sass.js +++ b/config/webpack/loaders/sass.js @@ -1,19 +1,31 @@ -const getStyleRule = require('shakapacker/package/utils/get_style_rule'); - -module.exports = getStyleRule(/\.(scss|sass)$/i, false, [ - { - loader: 'resolve-url-loader', - options: { - sourceMap: true - } - }, - { - loader: 'sass-loader', - options: { - sourceMap: true, - sassOptions: { - includePaths: ['app/frontend/src/stylesheets'] +module.exports = { + test: /\.(scss|sass)$/i, + exclude: /node_modules/, + use: [ + { + loader: require('mini-css-extract-plugin').loader + }, + { + loader: 'css-loader', + options: { + sourceMap: true, + importLoaders: 2 + } + }, + { + loader: 'resolve-url-loader', + options: { + sourceMap: true + } + }, + { + loader: 'sass-loader', + options: { + sourceMap: true, + sassOptions: { + includePaths: ['app/frontend/src/stylesheets'] + } } } - } -]); + ] +}; diff --git a/config/webpack/loaders/sass_erb.js b/config/webpack/loaders/sass_erb.js index 2224de175..113878dbe 100644 --- a/config/webpack/loaders/sass_erb.js +++ b/config/webpack/loaders/sass_erb.js @@ -1,22 +1,34 @@ -const getStyleRule = require('shakapacker/package/utils/get_style_rule'); - -module.exports = getStyleRule(/\.(scss|sass)\.erb$/, false, [ - { - loader: 'resolve-url-loader', - options: { - sourceMap: true - } - }, - { - loader: 'sass-loader', - options: { - sourceMap: true, - sassOptions: { - includePaths: ['app/frontend/src/stylesheets'] +module.exports = { + test: /\.(scss|sass)\.erb$/, + exclude: /node_modules/, + use: [ + { + loader: require('mini-css-extract-plugin').loader + }, + { + loader: 'css-loader', + options: { + sourceMap: true, + importLoaders: 2 } + }, + { + loader: 'resolve-url-loader', + options: { + sourceMap: true + } + }, + { + loader: 'sass-loader', + options: { + sourceMap: true, + sassOptions: { + includePaths: ['app/frontend/src/stylesheets'] + } + } + }, + { + loader: 'rails-erb-loader' } - }, - { - loader: 'rails-erb-loader' - } -]); + ] +}; diff --git a/config/webpack/webpack.config.js b/config/webpack/webpack.config.js index 95c33535d..fea60eeb4 100644 --- a/config/webpack/webpack.config.js +++ b/config/webpack/webpack.config.js @@ -43,7 +43,10 @@ const customConfig = { extensions: ['.jpg', '.jpeg', '.png', '.gif', '.tiff', '.ico', '.svg', '.eot', '.otf', '.ttf', '.woff', '.woff2', '.tsx', '.ts', '.erb', '.html', '.mjs', '.js', '.jsx', - '.sass', '.scss', '.css', '.module.sass', '.module.scss', '.module.css'] + '.sass', '.scss', '.css', '.module.sass', '.module.scss', '.module.css'], + fallback: { + assert: false + } } }; diff --git a/package.json b/package.json index ce62e2f78..01621d07e 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,8 @@ "@typescript-eslint/parser": "^4.28.1", "auto-ngtemplate-loader": "^3.1.0", "babel-loader": "8", + "babel-plugin-macros": "^3.1.0", + "core-js": "^3.21.1", "css-loader": "^6.7.1", "css-minimizer-webpack-plugin": "^3.4.1", "eslint": "~6.8.0", @@ -48,6 +50,7 @@ "rails-erb-loader": "^5.5.2", "react-refresh": "^0.11.0", "resolve-url-loader": "^4.0.0", + "sass": "^1.49.9", "sass-loader": "^12.6.0", "style-loader": "^3.3.1", "webpack-dev-server": "^4.7.4" diff --git a/yarn.lock b/yarn.lock index d21aef631..0a9f9809b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1139,7 +1139,7 @@ "@babel/helper-validator-option" "^7.16.7" "@babel/plugin-transform-typescript" "^7.16.7" -"@babel/runtime@7": +"@babel/runtime@7", "@babel/runtime@^7.12.5": version "7.17.2" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941" integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw== @@ -1534,6 +1534,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.4.tgz#e1cf817d70a1e118e81922c4ff6683ce9d422e26" integrity sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA== +"@types/parse-json@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" + integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== + "@types/prop-types@*": version "15.7.3" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7" @@ -2256,6 +2261,15 @@ babel-plugin-dynamic-import-node@^2.3.3: dependencies: object.assign "^4.1.0" +babel-plugin-macros@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz#9ef6dc74deb934b4db344dc973ee851d148c50c1" + integrity sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg== + dependencies: + "@babel/runtime" "^7.12.5" + cosmiconfig "^7.0.0" + resolve "^1.19.0" + babel-plugin-polyfill-corejs2@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz#440f1b70ccfaabc6b676d196239b138f8a2cfba5" @@ -2481,7 +2495,7 @@ checklist-model@0.2: resolved "https://registry.yarnpkg.com/checklist-model/-/checklist-model-0.2.4.tgz#123edfb21c338db2e9f8d5525348d9df3ce6b5a1" integrity sha1-Ej7fshwzjbLp+NVSU0jZ3zzmtaE= -chokidar@^3.5.3: +"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -2688,11 +2702,27 @@ core-js-pure@^3.8.1: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.21.1.tgz#8c4d1e78839f5f46208de7230cebfb72bc3bdb51" integrity sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ== +core-js@^3.21.1: + version "3.21.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.21.1.tgz#f2e0ddc1fc43da6f904706e8e955bc19d06a0d94" + integrity sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig== + core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= +cosmiconfig@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" + integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== + dependencies: + "@types/parse-json" "^4.0.0" + import-fresh "^3.2.1" + parse-json "^5.0.0" + path-type "^4.0.0" + yaml "^1.10.0" + cross-fetch@3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" @@ -3115,7 +3145,7 @@ envinfo@^7.7.3: resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== -error-ex@^1.2.0: +error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== @@ -4012,7 +4042,12 @@ immer@^9.0.6: resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.6.tgz#7a96bf2674d06c8143e327cbf73539388ddf1a73" integrity sha512-G95ivKpy+EvVAnAab4fVa4YGYn24J1SpEktnJX7JJ45Bd7xqME/SCplFzYFmTbrkwZbQ4xJK1xMTUYBkN6pWsQ== -import-fresh@^3.0.0: +immutable@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0.tgz#b86f78de6adef3608395efb269a91462797e2c23" + integrity sha512-zIE9hX70qew5qTUjSS7wi1iwj/l7+m54KWU247nhM3v806UdGj1yDndXj+IOYxxtW9zyLI+xqFNZjTuDaLUqFw== + +import-fresh@^3.0.0, import-fresh@^3.2.1: version "3.3.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== @@ -4346,6 +4381,11 @@ json-parse-better-errors@^1.0.2: resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== +json-parse-even-better-errors@^2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -4406,6 +4446,11 @@ lilconfig@^2.0.3: resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" integrity sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA== +lines-and-columns@^1.1.6: + version "1.2.4" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" + integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== + load-json-file@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" @@ -5082,6 +5127,16 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== + dependencies: + "@babel/code-frame" "^7.0.0" + error-ex "^1.3.1" + json-parse-even-better-errors "^2.3.0" + lines-and-columns "^1.1.6" + parseurl@~1.3.2, parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" @@ -5831,7 +5886,7 @@ resolve@^1.10.0, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.1 is-core-module "^2.2.0" path-parse "^1.0.6" -resolve@^1.9.0: +resolve@^1.19.0, resolve@^1.9.0: version "1.22.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== @@ -5922,6 +5977,15 @@ sass-loader@^12.6.0: klona "^2.0.4" neo-async "^2.6.2" +sass@^1.49.9: + version "1.49.9" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.49.9.tgz#b15a189ecb0ca9e24634bae5d1ebc191809712f9" + integrity sha512-YlYWkkHP9fbwaFRZQRXgDi3mXZShslVmmo+FVK3kHLUELHHEYrCmL1x6IUjC7wLS6VuJSAFXRQS/DxdsC4xL1A== + dependencies: + chokidar ">=3.0.0 <4.0.0" + immutable "^4.0.0" + source-map-js ">=0.6.2 <2.0.0" + scheduler@^0.20.2: version "0.20.2" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" @@ -6133,7 +6197,7 @@ sockjs@^0.3.21: uuid "^3.4.0" websocket-driver "^0.7.4" -source-map-js@^1.0.2: +"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== @@ -6914,7 +6978,7 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml@^1.10.2: +yaml@^1.10.0, yaml@^1.10.2: version "1.10.2" resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==