This is the 18th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
VueCLI
- Features: Based on
vue.js
The complete system for rapid development is called scaffolding - role
- Unify the architectural style of the project
- Initialize the configuration of project dependencies
- Provides single-file components
- Operation mode: Cli tool
- 🤩 Procedure:
Vue create Project name
Review “Front-end engineering”
- Custom builds: The source code resolves these issues before it becomes live code
Why build?
- Some code needs to be compiled (
css
.js
) to ensure browser compatibility- will
Less
orSass
Converted tocss
– > useless
The plug-in - will
ES6+
The new syntax is converted intoES5
-> Transform plug-inbabel
(Either a single file or an entire directory works.)
- will
- Some code needs to be compressed (
css
.js
.html
, pictures, etc.)- The compressed code is smaller, loads faster and saves bandwidth -> usage
minify
The plug-in
- The compressed code is smaller, loads faster and saves bandwidth -> usage
- Some code needs to be formatted and verified to unify the code style
Automated build
- All possible tasks, according to certain logic, arranged and combined together, and finally through a command to run all tasks
npm srcipts
How tasks are performed- parallel
parallel &
- serial
series &&
- Due to the
& Parallel execution
inwindows
Next does not work, usenpm-run-all
Plugin solution ->run-p
,run-s
- parallel
npm
Allows for thepackage.json
File, usescripts
Field definition script command- Declaration order (
package.json
)
/ / package. Json file "scripts": { "foo":"node bar.jss" } Copy the code
- Executing commands (command line)
/ / command line npm run foo Copy the code
- Declaration order (
Supplement to review
- Initialize the project (
npm init --yes
) Babel
(Compile conversion)- The installation
Babel
(npm install -g babel-core babel-cli
) - Install transcoding rules (
npm install -D babel-preset-env
) - Configure transformation rules (
.babelrc
File) - in
npm scripts
Add conversion command (babel src -d dist
) - Execute conversion command
- The installation
ESLint
(JS code format verification), different types of code need different tools to check- The installation
ESLint
(npm i eslint -g
) - Initialize the configuration file (
eslint --init
) - check
js
Code format
- The installation
StyleLint
:CSS
Code format check- The installation
styleLint
(npm install --global stylelint
) - Installation inspection Standard (
npm i --global stylelint-config-standard
) - Creating a configuration file (
.stylelintrc.json
) - check
CSS
Code style.- Single file (
stylelint path/filename.css
) - The entire project (
stylelint** / *.css
)
- Single file (
- The installation
What is theCSS
Preprocessor?
CSS
The preprocessor uses a specialized programming language forCSS
Added some programming features, and then compiled to normalCSS
File for project use- Currently more popular:
LESS
\SASS
LESS
It’s a dynamic style language. HereCSS
Gives dynamic language features such as variables, inheritance, operations, and functions.
Why use it?
- The structure is clear and easy to expand
- Easy to shield browser private syntax differences
- Multiple inheritance can be easily implemented
- Fully compatible with
css
The code.LESS
Only in theCSS
The grammar is extended, so the oldCSS
Code is also available withLESS
The code compiles together.
installed
- 🤩 Procedure
- Enter the project directory
CD project name
- Start the preview server
npm run serve
- Enter the project directory
Project to joinGit
Version management
gitgnore
File internal contains not togit
Push file name- Check for presence
git
warehousegit status
- create
git
warehousegit init
Push the local repository to the remote repository
- 🤩
Git remote add origin
- 🤩
git push -u origin master
-u
Represents the default, save to push the address
The directory structure
node_modules
: third-party package storage directory,npm
Downloaded packages are also includedpublic
: static resource directory. Internal static resources are simply copied without passing throughwebpack
index.html
src
: Resource Directoryassets
: Stores resources such as images used in the projectcomponents
: Component directoryrouter
: Routing module directorystore
: Container module directoryservices
: Stores interface function modulesstyles
: stores global stylesutils
: Stores the tool moduleviews
: Routing page component directoryApp.vue
: root component, which is eventually rendered toindex.html
In the#app
main.js
: Entry file, mountapp
.browerslistrc
: specifies the target browser range for the project@babel/preset-env
andAutoprefixer
To determine the transferjs
Features andcss
The prefix * *.editorconfig
: editor configuration file used to maintain the editor (orIDE
) unified code style.eslintrc.js
:ESLint
The configuration file.gitignore
:Git
Ignore configuration filesREADME.md
: Documentationbabel.config.js
:Babel
The configuration filepackage.json
: description file of the third-party package, recording the dependency information of the packagepackage-lock.json
: Records the version number of the package installed
Code specification and style guide
- Standardized code is easier to read, more maintainable, and more conducive to collaborative development
- Common code standard: Standard
User-defined verification rules
.eslintrc.js
extends
: Load rules for verificationrules
: User-defined rule Settings
- The server needs to be restarted to change the configuration file