Webpack2 Study Record-2

Source: Internet
Author: User
Tags npm scripts

This article creates a new W2 directory under Webpack-demo, learning webpack.config.js and the use of NPM scripts.

1, W2 under a new webpack.config.js, the contents are as follows

var path = require (' path '); module.exports = {  entry: './app/index.js ',  output: {    filename: ' Bundle.js ',    path:path.resolve (__dirname, ' dist ')  }};

This is the W2 directory for

At this point, you can execute the webpack command directly at the command line, some configuration parameters webpack.config.js file, reduce the command line to enter too many parameters.

2. Add a line to the Package.json

This can be combined with the NPM command to use the Webpack.

3. CD to W2 perform NPM run build

You can see that a dist directory is generated under W2, just like W1.

4, open index.html, the effect and w1 the same.

Webpack2 Study Record-2

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.