Npm commands (scripts)

Npm scripts help with performing repetitive tasks like minification, compilation, unit testing, linting, etc. The Silicon build system consists of a variety of JavaScript files, each performing specific tasks, and associated Npm scripts that execute these files.

The list of available Npm commands (scripts)
Command Description
npm install This command is used to install Node.js packages and their dependencies in a project. The dependencies are listed in a "package.json" file in the project's root directory, under the "dependencies" and "devDependencies" sections.
npm run dev Builds and minifies styles and scripts, copies vendor files from the node_modules directory to the assets/vendor folder, initiates a watch process to detect files changes, and starts a local development server with hot reloading. This is the primary command to utilize when customizing the template.
npm run build Builds both expanded and minified versions of styles and scripts, copies vendor files from the node_modules directory to the assets/vendor folder, and runs HTML validation checks.
npm run styles This command executes the following two style-related commands sequentially: styles:compile and styles:minify
npm run styles:compile This command first lints SCSS files to ensure they adhere to Bootstrap coding standards. It then compiles the SCSS file located at src/scss/theme.scss into a CSS file at assets/css/theme.css, and generates a corresponding source map file. The source map facilitates easier debugging by mapping the CSS styles back to their original SCSS sources.
npm run styles:minify This command minifies the compiled CSS files, reducing their file size for better performance in production environments. It targets CSS files located in the assets/css folder, optimizing them for faster loading times.
npm run scripts This command executes the following two scripts-related commands sequentially: scripts:compile and scripts:minify
npm run scripts:compile This command first lints the source JavaScript files from src/js directory to ensure code quality. It then bundles them into a single file assets/theme.js and generates a corresponding source map file. The source map aids in debugging by mapping the bundled JavaScript back to its original source files.
npm run scripts:minify This command minifies and uglifies the assets/js/theme.js file, generating assets/js/theme.min.js, reducing its size and obfuscating the code for improved performance and security. It also generates an associated source map file to assist in debugging the minified JavaScript.
npm run vendor This command copies vendor files listed under the dependencies object in the package.json file from the node_modules directory to the assets/vendor folder.
npm run validate Executes validation checks on all .html files, ensuring compliance with W3C markup validity rules. This process utilizes the HTML-validate plugin, which is configured through the .htmlvalidate.json file.
npm run watch Initiates a watch process to monitor changes in .css, .js, and .html files, simultaneously launching a local development server equipped with hot reloading, powered by Browsersync.
Top