Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DQA-9652: Extend target build-assets to work with bcl #799

Draft
wants to merge 4 commits into
base: release/10.x
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions config/commands/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ command:
build-npm-packages: ${toolkit.build.npm.packages}
theme-task-runner: ${toolkit.build.npm.theme-task-runner}
ecl-command: ${toolkit.build.npm.ecl-command}
bcl-command: ${toolkit.build.npm.bcl-command}
2 changes: 1 addition & 1 deletion config/runner/toolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ toolkit:
custom-code-folder: 'lib'
npm:
theme-task-runner: ecl-builder
packages: '@ecl/builder @ecl/preset-ec @ecl/preset-eu @ecl/preset-reset'
packages: '@ecl/builder @ecl/preset-ec @ecl/preset-eu @ecl/preset-reset @openeuropa/bcl-builder @openeuropa/bcl-bootstrap @openeuropa/bcl-theme-default'
ecl-command: 'styles scripts'
scss:
validate: 'false'
Expand Down
19 changes: 16 additions & 3 deletions docs/guide/building-assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ like shown below:
toolkit:
build:
npm:
theme-task-runner: ecl-builder gulp
packages: '@ecl/builder pikaday moment gulp gulp-concat gulp-sass gulp-clean-css gulp-minify'
theme-task-runner: ecl-builder gulp bcl-builder
packages: '@ecl/builder pikaday moment gulp gulp-concat gulp-sass gulp-clean-css gulp-minify @openeuropa/bcl-builder @openeuropa/bcl-bootstrap @openeuropa/bcl-theme-default'
ecl-command: 'styles scripts'

Command to run:
Expand All @@ -41,7 +41,7 @@ Command to run:

Edit the config file in order to fit your needs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
('ecl-builder.config.js' and/or 'gulpfile.js')
('ecl-builder.config.js', 'bcl-builder.config.js' and/or 'gulpfile.js')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Depending on the chosen runners a config file will be created on the theme root folder.
Expand All @@ -68,6 +68,19 @@ To use other command listed on 'ecl-builder' options an additional parameter can
// Execute an available command from the ecl-builder list - Get help:
docker-compose exec web ./vendor/bin/run toolkit:build-assets --ecl-command=help

Build theme assets (bcl-builder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Toolkit compiles the Css and Js files, defined in the configuration file
'bcl-builder.config.js' as entry and destination paths.
The bcl-builder command used for this action is 'styles'. This the default command.

To use other command listed on 'bcl-builder' options an additional parameter can be provided:
'--bcl-command'
.. code-block::

// Execute an available command from the bcl-builder list - Get help:
docker-compose exec web ./vendor/bin/run toolkit:build-assets --bcl-command=help

Define 'default-theme'
^^^^^^^^^^^^^^^^^^^
Expand Down
38 changes: 38 additions & 0 deletions resources/assets/bcl-builder.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
const pkg = require('./package.json');

const isProd = process.env.NODE_ENV === 'production';
const outputFolder = path.resolve(__dirname);
const nodeModules = path.resolve(__dirname, "./node_modules");

// SCSS includePaths
const includePaths = [nodeModules];

const banner = `${pkg.name} - ${
pkg.version
} Built on ${new Date().toISOString()}`;

module.exports = {
scripts: [],
styles: [
{
entry: path.resolve(__dirname, 'sass/style.scss'),
dest: path.resolve(outputFolder, 'css/style.min.css'),
options: {
includePaths,
minify: true,
sourceMap: isProd ? 'file' : true,
},
},
{
entry: path.resolve(__dirname, 'sass/style.scss'),
dest: path.resolve(outputFolder, 'css/style.min.css'),
options: {
includePaths,
minify: true,
sourceMap: isProd ? 'file' : true,
},
},
],
copy: []
};
10 changes: 10 additions & 0 deletions tests/fixtures/commands/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,19 @@
->exec('npm list @ecl/preset-ec || npm install @ecl/preset-ec --save-dev')
->exec('npm list @ecl/preset-eu || npm install @ecl/preset-eu --save-dev')
->exec('npm list @ecl/preset-reset || npm install @ecl/preset-reset --save-dev')
->exec('cp /test/toolkit/resources/assets/bcl-builder.config.j ... l-builder.config.js')
->exec('npm list @openeuropa/bcl-builder || npm install @openeuropa/bcl-builder --save')
->exec('npm list @openeuropa/bcl-bootstrap || npm install @openeuropa/bcl-bootstrap --save')
->exec('npm list @openeuropa/bcl-theme-default|| npm install @openeuropa/bcl-theme-default --save')
[Simulator] Simulating Exec('./node_modules/.bin/ecl-builder styles')
->dir('/test/toolkit/tests/sandbox/BuildCommandsTest/code/theme')
[Simulator] Running ./node_modules/.bin/ecl-builder styles in /test/toolkit/tests/sandbox/BuildCommandsTest/code/theme
[Simulator] Simulating Exec('./node_modules/.bin/ecl-builder scripts')
->dir('/test/toolkit/tests/sandbox/BuildCommandsTest/code/theme')
[Simulator] Running ./node_modules/.bin/ecl-builder scripts in /test/toolkit/tests/sandbox/BuildCommandsTest/code/theme
[Simulator] Simulating Exec('./node_modules/.bin/bcl-builder styles')
->dir('/test/toolkit/tests/sandbox/BuildCommandsTest/code/theme')
[Simulator] Running ./node_modules/.bin/bcl-builder styles in /test/toolkit/tests/sandbox/BuildCommandsTest/code/theme
[Simulator] Simulating Exec('./node_modules/.bin/bcl-builder scripts')
->dir('/test/toolkit/tests/sandbox/BuildCommandsTest/code/theme')
[Simulator] Running ./node_modules/.bin/bcl-builder scripts in /test/toolkit/tests/sandbox/BuildCommandsTest/code/theme