Webpack First Knowledge

Source: Internet
Author: User

1. Installation

Global Installation:

NPM Install Webpack-g

Install in the project directory:

NPM Install Webpack--save-dev

Package File Base command:

Webpack Source.js Bundle.js

2. Configuration

Create a webpack.config.js profile in the directory, or you can specify the configuration file with --config ; In a configuration file, specify a configuration file with Module.exports, and each configuration parameter is in the form of a key-value pair:

(1) Portal Configuration Entry: string/Array/object

String: Single entry file

Array: A single entry, but there are multiple interdependent files

Object: Multiple entry file, at this time the corresponding export filename will be changed to multi-exit form, or will be error

(2) Export configuration output: Object form. where the path and filename fields represent a packaged path and a packaged file name, note that when there are multiple portals, the packaged file name is modified to be automatically generated.

(3) Example:

Const PATH = require (' path '); module.exports = {    entry: {        main: './src/script/main.js ',        A: './src/script/ A.js '    },    output: {        path:path.resolve (__dirname, ' Dist/js '),        filename: ' [name].js '    }}

Webpack First Knowledge

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.