Webpack Configuring the installation of the SAN

Source: Internet
Author: User
Tags naming convention

Objective

Just started to learn SAN, not familiar with the Webpack, the configuration of the SAN environment process is a bit difficult, rare out, or record!

Process

First, open the command line under the new project folder, first install Webpack (Note: The file name conforms to the naming convention)

NPM Init-y (can also be initialized with NPM init if the content in the Package.json is set)
NPM install--save-dev webpacknpm instal  --save-dev webpack-cli

After executing the above command, create a new two folder in the project folder./src and./dist, respectively, for storing index.js files and index.html files, at which time the directory is

--Dist---index.html--src---index.js--node_modules--package-  Lock. JSON--package.json

Webpack need to have a portal file for the './src/index.js ' file, create a new folder in the project file, with a portal file that needs to be packaged out

NPX Webpack (used in node 8.0 +)

After installation, a file named Bundle.js is generated in the./dist file, in addition, it is worth mentioning that in the project, because JS and style will be frequently modified, you can use the automatic refresh function to help implement, installation instructions

NPM Install Webpack-dev-server--save-dev

Modify the contents of script in Package.json after installation

"Script": {    "start""webpack-dev-server--mode Development  ",    "build""webpack--mode Production "}
Webpack--mode Development (Webpack--mode production)

You can choose one of the above ways to package, the specific difference reference https://webpack.js.org/concepts/mode/

Export the./src/index.js package to the./dist/main.js

About the Webpack.config.js file, you can configure it yourself

In addition, Webpack supports the introduction of any type of file via loader

NPM Install--save-dev Style-loader css-loader-g

If you need to use Babel-loader to convert JS code, you also need to install Babel-loader

NPM Install--save-dev Babel-loader babel-core

Not to be continued ...

Webpack Configuring the installation of the SAN

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.