var path = require (' path '); The module for path resolution in node const Htmlwebpackplugin =require (' Html-webpack-plugin '); module.exports = {//Portal File entry: './src/app. JS ',//Export file output:{//Export file name filename: ' index.js ',//Export file path Path:path.resolve (__dirnam E, ' Dist '), Publicpath: "/"},//webpack-dev-server Server directory Devserver: {contentbase: './dist/'}, Plug-in plugins:[//automatically generate HTML files in the export path, the function can accept an object: template for generating a new HTML file of the templates file new Htmlwebpackplugin ({ Template: './src/index.html '}],//module processing module:{//Processing rules rules:[//processing CSS {//matching file test:/\.css$/,//loader used, processing order from post to forward processing use:[' Style-loader ', ' css-loader '},//Processing file: img ... {//Match file test:/\. (png|jpg|gif) $/, use:[{loader: ' Url-loader ',//loader some of the files when processingConfiguration options options:{//Size limit (in bytes): Less than this limit will be converted to Base64 Limit:10 24}}]},//handling react JSX syntax and ES6 syntax {// Match file test:/\.js$/,//Exclude all Files under Node_modules file Exclude:path.resolve (__dirname , ' node_modules '),//Use of loader information use:{loader: ' Babel-loader ', options:{//Presets used: Env handles ES6 syntax, react handles JSX syntax, stage-0 handles react for ES6 partial syntax unsupported issues presets:[' env ', ' react ', ' stage-0 '}}}}}
{ "name":"webpack-demo", "version":"1.0.0", "description":"", "main":"index.js", "scripts":{ "webpack":"webpack", "start":"webpack-dev-server --open" }, "author":"", "license":"ISC", "devDependencies":{ "babel-cli":"^6.26.0", "babel-core":"^6.26.0", "babel-loader":"^7.1.2", "babel-preset-env":"^1.6.1", "babel-preset-react":"^6.24.1", "babel-preset-stage-0":"^6.24.1", "css-loader":"^0.28.7", "file-loader":"^1.1.5", "html-webpack-plugin":"^2.30.1", "style-loader":"^0.19.0", "url-loader":"^0.6.2", "webpack":"^3.10.0", "webpack-dev-server":"^2.9.7" }, "dependencies":{ "react":"^16.2.0", "react-dom":"^16.2.0" }}
REACT-TODOMVC Scaffolding