The purpose of this stack is to allow linting, building and watching of your assets, while adding as little overhead and configuration as possible to your project.
core is the base package which allows you to install any of the following packages for your project:
csse2ehtmlimagesjavascriptsvgtwig
Add core via:
yarn add @factorial/stack-coreAfterwards run
yarn factorial initwhich allows you to select which packages you want to install.
core will then automatically add those packages to your project and create a .factorialrc.js with the required configuration.
In this file you can also add the following options.
assetFolders, default: []
Asset folders for fonts, icons, etc., relative from rootFolder. These files will be copied to distFolder when creating a build.
cssFiles, default: []
The CSS entry files, relative from rootFolder. These files will be used to create a build.
cssTokens
Please refer to packages/css/README.md for more information.
distFolder, default: "dist"
The folder where the build files will be put
imageFolders, default: []
Folders that contain image files.
jsFiles, default: []
The JavaScript entry files, relative from rootFolder. These files will be used to create a build.
rootFolder, default: "src"
The root folder for jsFiles, cssFiles, assetFolders, imageFolders, svgFolders
svgFolders, default: []
Folders that contain SVG files.
targets, default:
browsers: "last 2 Chrome versions, last 2 Firefox versions, last 2 Safari versions, last 2 ios versions, last 2 ChromeAndroid versions, last 2 Edge versions";If not already done via yarn factorial init, create the configuration file like this:
// .factorialrc.js
module.exports = {
assetFolders: ["fonts/", "icons/"],
cssFiles: ["index.css"],
distFolder: "build",
imageFolders: ["images"],
jsFiles: ["index.js"],
svgFolders: ["svgs"],
rootFolder: "source",
};NOTE: You can also omit this file if the default configuration is sufficient.
You can either set a targets or browserslist key in your package.json. The former wins over the latter.
yarn factorial initThis will allow you to pick the packages you want to install and afterwards create a configuration file. If it already exists, you can skip that step.
yarn factorial lintThis will lint all files (found in rootFolder) based on your installed packages once.
You can also lint a specific type via e.g.:
yarn factorial lint --only cssVice versa, if you want to lint all but one type, you can use --skip:
yarn factorial lint --skip cssBoth params (--only and --skip) accept a comma separated list.
If you want to lint only staged files, you can do that by adding --staged:
yarn factorial lint --stagedPlease note, that this is only supported by the css, javascript and vue packages.
yarn factorial optimizeThis will optimize all files (found in rootFolder) based on your installed packages once.
You can also optimize a specific type via e.g.:
yarn factorial optimize --only svgyarn factorial buildThis will create the build files and sourcemaps in distFolder based on your installed packages. If they should be minified, you can run this command with setting the NODE_ENV to "production":
NODE_ENV=production yarn factorial buildWhen referencing/importing assets in your component files (import in your JS files or url in your CSS file), the referenced/imported files are copied into your build folder and the paths are adapted. That means, the assets are not inlined.
You can also build a specific type via e.g.:
yarn factorial build --only cssyarn factorial watchThis will watch all files in rootFolder for changes and lint them. If you also want to create a build, when files changed, pass --build:
yarn factorial watch --buildIf a specific command should be run every time the build has finished, you can pass that command using --afterBuild:
yarn factorial watch --build --afterBuild yarn run someCommandIf you want to exclude certain types from watching, you can do so by setting the --skip option:
yarn factorial watch --skip htmlYou can run tests based on your installed packages with
yarn factorial testYou can also test a specific type via e.g.:
yarn factorial test --only jsPackages can also export custom commands (e.g. sprite by the SVG package). When running a custom command, core would simply execute the related external task (while core has more sophisticated functionality for the fixed tasks).
You can run lint, test and watch with additional params like this:
yarn factorial lint --fixEvery param that comes after the command name (lint, watch, test) is passed through, so you can overwrite or define settings.
NOTE:: Please note that linting runs all tasks, so additional params would passed through to all of them. This might actually cause an error when one package does not support that param and therefore throws an error. If that is the case, try running a more specific command like yarn factorial lint --only css --fix.
Passing additional params to build is not supported at the moment.
When running a command, you can choose to only run specific packages by using --only. Let's say, you only want to lint CSS and JS files, you could run:
yarn factorial lint --only css,jsAlternatively you can also skip packages using the --skip option:
yarn factorial lint --skip css,jsYou can lint this project by running:
yarn lintThis will use the same eslint configuration as exposed by the javascript package.
We are using Conventional commits.
To create a release, please run any of:
yarn core:release
yarn css:release
yarn e2e:release
yarn html:release
yarn images:release
yarn javascript:release
yarn svg:release
yarn twig:releaseThis will automatically update the changelog based on the commit messages.
NOTE: This only updates the changelog, creates a tag and commit. It does not push to GitHub or publish the package on npm. This needs to be done manually.