var path = require('path'), webpack = require('webpack'), HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: ['webpack/hot/dev-server', path.resolve(__dirname, './app.js')], output: { path: path.resolve(__dirname, './__build__'), filename: 'bundle.js' }, devServer: { inline: true, port: 8099 }, module: { loaders: [{ test: /\.js?$/, exclude: /(node_modules|bower_components)/, loader: 'babel', query: { presets: ['es2015', 'react'] } }] }, plugins: [ new HtmlWebpackPlugin({ template: './index.html' }), new webpack.HotModuleReplacementPlugin() ] };
上面第五行 ‘./app.js' 是你的js入口文件
安装完成之后运行命令
1、根目录下执行命令,其中一个:
npm run build 线上目录 npm run dev 开发目录
2.浏览器直接访问::8099/index.html
解决方案二:代码链接