npm i -g yarnnpm i -g gulpnpm i -g bem-tools-coregit clone https://github.com/andreyalexeich/gulp-pug-starter.gitcd gulp-pug-starteryarn set version berryyarnyarn run dev (development mode)yarn run build command (assembly mode)If you did everything right, you should open a browser with a local server. The assembly mode involves the optimization of the project: image compression, minification of CSS and JS files for downloading to the server.
gulp-pug-starter
├── dist
├── gulp-tasks
├── src
│ ├── blocks
│ ├── fonts
│ ├── img
│ ├── js
│ ├── styles
│ ├── views
│ └── .htaccess
├── gulpfile.babel.js
├── webpack.config.js
├── package.json
├── .yarnrc.yml
├── .babelrc.js
├── .bemrc.js
├── .eslintrc.json
├── .stylelintrc
├── .stylelintignore
└── .gitignore
.babelrc.js - Babel settings.bemrc.js - BEM settings.eslintrc.json - ESLINT settings.gitignore - ban on tracking Git files.stylelintrc - StyleLint settings.stylelintignore - ban on tracking STYLELINT files.yarnrc.yml - Setting Yarngulpfile.babel.js - GULP settingswebpack.config.js - Webpack settingspackage.json - List of Dependenciessrc folder - used during development:src/blockssrc/fontssrc/imgsrc/jssrc/views/pagessrc/stylessrc/viewssrc/.htaccessdist folder is a folder from which a local server is launched for development (when starting yarn run dev )gulp-tasks folder-a folder with GULP Tasks yarn run lint:styles - Check SCSS files. For VSCODE, you need to install a plugin. For Webstorm or Phpstorm, you need to enable StyleLint in Languages & Frameworks - Style Sheets - Stylelint (errors will be automatically fixed while saving the file)yarn run dev - Starting a server for project developmentyarn run build - Collect a project with optimization without starting the serveryarn run build:views - compile pug filesyarn run build:styles - compile SCSS filesyarn run build:scripts - Collect JS Failesyarn run build:images - collect imagesyarn run build:webp - to adjust the images to the .webp formatyarn run build:sprites - Collect sproutsyarn run build:fonts - collect fontsyarn run build:favicons - Collect Favikonkiyarn run build:gzip - Collect Apache configurationyarn run bem-m -Add BEM Blockyarn run bem-c - Add the componentyarn run lint:styles --fix -Fix errors in SCSS files according to StyleLint settingsyarn run lint:scripts - Check JS Failyarn run lint:scripts --fix -Fix errors in JS files according to ESLINT settings src/blocks/modulessrc/views/index.pug file (or to the necessary page file where the block will be called)src/blocks/modules/_modules.scss filesrc/js/import/modules.jsAn example of the structure of the folder with a BEM block:
blocks
├── modules
│ ├── header
│ │ ├── header.pug
│ │ ├── header.js
│ │ ├── header.scss
In order not to manually create the corresponding folder and files, it is enough to prescribe the following commands in the console:
yarn run bem-m my-block -to create a BEM block in src/block/modules (for the main BEM blocks), where my-block is the name of the BEM block (after the creation you need to delete the contents of the BAM block jS file);yarn run bem-с my-component -to create a component in src/blocks/components (for components), where my-component is the name of the component (after creating you need to delete the contents of the BEM component JS file);src/blocks/componentssrc/views/index.pug (or to the necessary page file from where the component will be called)src/blocks/components/_components.scss filesrc/js/import/components.js filesrc/views/pages foldersrc/views/layouts/default.pug template templatesrc/views/index.pugsrc/fonts folder.woff formats and .woff2src/styles/base/_fonts.scss filesrc/img folder.webp format. Detailed information on use heresrc/img/favicon folder and have a size of at least 1024px x 1024px To create sprites .svg image should be in the src/img/sprites folder. For example, we have icon-1.svg , icon-2.svg and icon-3.svg files, and we must contact icon-2.svg . To do this, in HTML you need to use the use tag:
svg
use ( xlink:href = "img/sprites/sprite.svg#logo" )Change the styles of SVG-icons from the sprite in CSS:
svg use {
fill : red;
}There is a situation when the styles of the icons cannot be changed. This is due to the fact that when exporting from FIGMA to SVG, an extra code is added. For example:
< svg width =" 18 " height =" 19 " viewBox =" 0 0 18 19 " fill =" none " xmlns =" http://www.w3.org/2000/svg " >
< path d =" M4.90918 4.04542L13.091 9.54088L4.90918 14.9545L4.90918 4.04542Z " fill =" #1B1B1D " />
</ svg > It is necessary to remove fill="none" and fill="#1B1B1D" . It should turn out like this:
< svg width =" 18 " height =" 19 " viewBox =" 0 0 18 19 " xmlns =" http://www.w3.org/2000/svg " >
< path d =" M4.90918 4.04542L13.091 9.54088L4.90918 14.9545L4.90918 4.04542Z " />
</ svg > node_modules folderyarn add package_name command import $ from "jquery" ;src/styles/vendor/_libs.scss fileUse this assembly.
Tell me about bugs, put a star, be the Telegram ton to me for beer?
For all questions, write in Telegram