Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/optimization.config.js
Original file line number Diff line number Diff line change
@@ -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`;

Expand All @@ -10,7 +10,7 @@ module.exports = {
minimize: isProduction,
usedExports: 'global',
runtimeChunk: {
name: 'commons/treeshaking.bundle.js'
name: `commons/treeshaking.${bundleKey}.js`
},
splitChunks: {
chunks: 'initial',
Expand All @@ -21,15 +21,15 @@ 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
treeshaking: {
test: test([nodeModules]),
minChunks: 2,
enforce : true,
name: 'commons/treeshaking.bundle.js',
name: `commons/treeshaking.${bundleKey}.js`,
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion config/sass.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
};
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tasks/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
41 changes: 41 additions & 0 deletions test/.febuild.js
Original file line number Diff line number Diff line change
@@ -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) => `<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
categories="[${prefix}.${category}]"
cssProcessor="[default:none, min:none]"
jsProcessor="[default:none, min:none]" />`
}
};
}
11 changes: 11 additions & 0 deletions test/src/minimal/.febuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

module.exports = {
babel: {
use: {
options: {
presets: [['@babel/preset-env', { useBuiltIns: 'usage', corejs: 3, debug: true }]]
}
}
},
};
44 changes: 23 additions & 21 deletions utils/renderSass.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,25 @@ 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');

// 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));

Expand All @@ -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;
}
});
};
};