Webpack2 Hot Load JS file

Source: Internet
Author: User

As long as the normal hot load as long as the following configuration is good

Package.json

{  "devdependencies": {    "webpack": "^2.6.1",    "webpack-dev-server": "^2.4.5"   },  " Scripts ": {    " start ":" Webpack-dev-server "  }}

Webpack.config.js

Module.exports = {    + '/js/test.js ',    output: {        //  Note this is Publicpath        publicpath: "/dist/",        "Bundle_test.js"    }}

To use ES6 syntax, load the Babel file, and note that you need to install BABEL-CLI first

Package.json as follows:

{  "devdependencies": {      "babel-cli": "^6.24.1",    "Babel-core": "^6.25.0"  ,    "Babel-loader": "^7.0.0",    "babel-preset-es2015": "^6.24.1",    " Babel-preset-react ":" ^6.24.1 ",    " Webpack ":" ^2.6.1 ",    " webpack-dev-server ":" ^ 2.4.5 "  },  " Scripts ": {    " start ":" Webpack-dev-server "}  }

Webpack.config.js as follows:

Module.exports = {    + '/js/test.js ',    output: {        "/dist/",        "bundle_test.js "    },    module: {        loaders: [            {                /\.json$/,                " Json-loader "            } ,            {                /\.js$/,                "Babel-loader"            }        ]}    }

and add a. babelrc file, as follows:

{    "presets": ["es2015", "React"]}

Webpack2 Hot Load JS file

Related Article

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.