diff --git a/config/optimization.config.js b/config/optimization.config.js index aac5361..7c3ae0a 100644 --- a/config/optimization.config.js +++ b/config/optimization.config.js @@ -1,5 +1,5 @@ const path = require('path') -const { isProduction, excludedFromVendors } = require('./general.config'); +const { isProduction, excludedFromVendors, bundleKey } = require('./general.config'); const checkChunk = require('../utils/checkChunk'); const nodeModules = `node_modules`; @@ -10,7 +10,7 @@ module.exports = { minimize: isProduction, usedExports: 'global', runtimeChunk: { - name: 'commons/treeshaking.bundle.js' + name: `commons/treeshaking.${bundleKey}.js` }, splitChunks: { chunks: 'initial', @@ -21,7 +21,7 @@ module.exports = { test: test([nodeModules], excludedFromVendors), minChunks: 2, enforce : true, - name: 'commons/vendors.bundle.js', + name: `commons/vendors.${bundleKey}.js`, // used on at least 2 modules }, // Treeshakes common imports, if used in more than 2 clientlibs @@ -29,7 +29,7 @@ module.exports = { test: test([nodeModules]), minChunks: 2, enforce : true, - name: 'commons/treeshaking.bundle.js', + name: `commons/treeshaking.${bundleKey}.js`, } } } diff --git a/config/sass.config.js b/config/sass.config.js index dc709c1..5e04620 100644 --- a/config/sass.config.js +++ b/config/sass.config.js @@ -6,5 +6,7 @@ const outputStyle = isProduction ? 'compressed' : 'expanded'; module.exports = { includePaths, - outputStyle + outputStyle, + // for any https://sass-lang.com/documentation/js-api/interfaces/options/ options + adicionalOptions: {} }; diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8743b88..6749054 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,3 +1,10 @@ +# [6.0.0](https://github.com/Netcentric/fe-build/compare/v4.0.2...v5.0.0) (2025-03-13) + +* Removal of SASS depracated legacy JS API. +(breaking changes since all scss code should be soon remove depracation code) + + + # [5.0.0](https://github.com/Netcentric/fe-build/compare/v4.0.2...v5.0.0) (2025-01-29) diff --git a/package-lock.json b/package-lock.json index a90ed9e..2af615f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@netcentric/fe-build", - "version": "4.0.2", + "version": "5.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@netcentric/fe-build", - "version": "4.0.2", + "version": "5.0.0", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.26.7", @@ -356,25 +356,25 @@ } }, "node_modules/@babel/helpers": { - "version": "7.26.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.7.tgz", - "integrity": "sha512-8NHiL98vsi0mbPQmYAGWwfcFaOy4j2HY49fXJCfuDcdE7fMIsH9a7GdaeXpIBsbT7307WU8KCMp5pUVDNL4f9A==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.10.tgz", + "integrity": "sha512-UPYc3SauzZ3JGgj87GgZ89JVdC5dj0AoetR5Bw6wj4niittNyFh6+eOGonYvJ1ao6B8lEa3Q3klS7ADZ53bc5g==", "license": "MIT", "dependencies": { - "@babel/template": "^7.25.9", - "@babel/types": "^7.26.7" + "@babel/template": "^7.26.9", + "@babel/types": "^7.26.10" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.26.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.7.tgz", - "integrity": "sha512-kEvgGGgEjRUutvdVvZhbn/BxVt+5VSpwXz1j3WYXQbXDo8KzFOPNG2GQbdAiNq8g6wn1yKk7C/qrke03a84V+w==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.10.tgz", + "integrity": "sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==", "license": "MIT", "dependencies": { - "@babel/types": "^7.26.7" + "@babel/types": "^7.26.10" }, "bin": { "parser": "bin/babel-parser.js" @@ -1632,9 +1632,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.26.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.7.tgz", - "integrity": "sha512-AOPI3D+a8dXnja+iwsUqGRjr1BbZIe771sXdapOtYI531gSqpi92vXivKcq2asu/DFpdl1ceFAKZyRzK2PCVcQ==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.10.tgz", + "integrity": "sha512-2WJMeRQPHKSPemqk/awGrAiuFfzBmOIPXKizAsVhWH9YJqLZ0H+HS4c8loHGgW6utJ3E/ejXQUsiGaQy2NZ9Fw==", "license": "MIT", "dependencies": { "regenerator-runtime": "^0.14.0" @@ -1644,14 +1644,14 @@ } }, "node_modules/@babel/template": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", - "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz", + "integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==", "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.25.9", - "@babel/parser": "^7.25.9", - "@babel/types": "^7.25.9" + "@babel/code-frame": "^7.26.2", + "@babel/parser": "^7.26.9", + "@babel/types": "^7.26.9" }, "engines": { "node": ">=6.9.0" @@ -1676,9 +1676,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.7.tgz", - "integrity": "sha512-t8kDRGrKXyp6+tjUh7hw2RLyclsW4TRoRvRHtSyAX9Bb5ldlFh+90YAYY6awRXrlB4G5G2izNeGySpATlFzmOg==", + "version": "7.26.10", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.10.tgz", + "integrity": "sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==", "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.25.9", diff --git a/tasks/run.js b/tasks/run.js index 6e72497..cf7fecc 100644 --- a/tasks/run.js +++ b/tasks/run.js @@ -19,7 +19,7 @@ if (config && config.general && config.general.configFile) { } else { // No configFile set then lookup for configurations files const configPattern = `**/${config.general.extendConfigurations}`; - const availableBuilds = glob.sync(configPattern, { cwd: config.general.rootPath, ignore: ['./node_modules/**'] }); + const availableBuilds = glob.sync([configPattern, `${configPattern}.js`], { cwd: config.general.rootPath, ignore: ['./node_modules/**'] }); // log what is happening if (availableBuilds.length === 0) { diff --git a/test/.febuild.js b/test/.febuild.js new file mode 100644 index 0000000..e213b60 --- /dev/null +++ b/test/.febuild.js @@ -0,0 +1,41 @@ +const path = require('path'); + +module.exports = function (defaultConfig) { + const rootPath = __dirname; + const sourcesPath = path.join(rootPath, 'src'); + const common = path.join(sourcesPath, 'common'); + const includePaths = [path.join(common, 'styles'), defaultConfig.general.nodeModules]; + + return { + general: { + projectKey: 'febuild', + rootPath, + sourcesPath, + destinationPath: path.join(rootPath, 'dist'), + common, + sourceKey: 'src', + bundleKey: 'dist' + }, + sass: { + includePaths + }, + resolve: { + alias: { + common + } + }, + clientlibs: { + override: true, + skipCategories: ['febuild.author'] + }, + templates: { + clientlibTemplate: (category, prefix) => ` +` + } + }; +} diff --git a/test/src/minimal/.febuild.js b/test/src/minimal/.febuild.js new file mode 100644 index 0000000..af8df5a --- /dev/null +++ b/test/src/minimal/.febuild.js @@ -0,0 +1,11 @@ +const path = require('path'); + +module.exports = { + babel: { + use: { + options: { + presets: [['@babel/preset-env', { useBuiltIns: 'usage', corejs: 3, debug: true }]] + } + } + }, + }; diff --git a/utils/renderSass.js b/utils/renderSass.js index 59260e2..50d47b5 100644 --- a/utils/renderSass.js +++ b/utils/renderSass.js @@ -6,7 +6,7 @@ const { log } = require('./log'); module.exports = function renderSass(dest, file, config, cb, write = false) { // extract sass only configs - const { outputStyle, includePaths, failOnError } = config.sass; + const { outputStyle, includePaths, failOnError, adicionalOptions } = config.sass; // proper extension const destFile = dest.replace('.scss', '.css'); @@ -14,26 +14,17 @@ module.exports = function renderSass(dest, file, config, cb, write = false) { // url of the saved file const outFile = path.join(config.general.destinationPath, destFile); + // extract from config - sass.render({ - file, + const compiled = sass.compileAsync(file, { outputStyle, - includePaths, - outFile, - sourceMap: !config.general.isProduction - }, (error, result) => { - // log if there are any errors - if (error) { - log(__filename, `${destFile} ${error.message}!`, '', 'error'); - // if set to exit on error, you might not want to exit on all cases - if (failOnError) { - process.exit(1); - } else { - log(__filename, `Sass file not rendered - ${path.basename(destFile)}`, ``, 'error'); - // skip the rest - return; - } - } + loadPaths:includePaths, + sourceMap: !config.general.isProduction, + // adicional config from https://sass-lang.com/documentation/js-api/interfaces/options/ + ...adicionalOptions + }); + + compiled.then((result) => { // create folder if it does not exist mkFullPathSync(path.dirname(outFile)); @@ -52,7 +43,18 @@ module.exports = function renderSass(dest, file, config, cb, write = false) { result.destFile = destFile; // log and call back - log(__filename, `Sass rendered - ${path.basename(destFile)}`, ` (Duration ${result.stats.duration}ms)`, 'success'); + log(__filename, `Sass rendered - ${path.basename(destFile)}`, ` -- `, 'success'); return cb(result, outFile); + + }).catch((error) => { + log(__filename, `${destFile} ${error.message}!`, '', 'error'); + // if set to exit on error, you might not want to exit on all cases + if (failOnError) { + process.exit(1); + } else { + log(__filename, `Sass file not rendered - ${path.basename(destFile)}`, ``, 'error'); + // skip the rest + return; + } }); -}; +}; \ No newline at end of file