我根据这个文档(https://fakefish.github.io/react-webpack-cookbook/Configuring-react-js.html)尝试webpack.在进行到浏览器自动刷新时出错?不知道为什么?有人可以成功运行么?
Terminal截图
浏览器截图
package.json
webpack.config.js
题主能否将package.json和webpack config的截图发出来,前两天正好帮同事解决了这个问题,或许可以帮上忙
---- 2015-12-31更新如下 ----
尝试下如下修改:
webpack config文件的entry中仅保留
main.js
build/index.html
文件中删除<script src="http://localhost:8080/webpack-dev-server.js"></script>
webpack-dev-server
安装成功了么?可以在命令行里直接运行么?
遇到过这个安装失败的
webpack.config.js文件中,加了HotModuleReplacementPlugin插件配置没,我的webpack.config.js内容参考下:
var webpack = require('webpack')
var path = require('path');
module.exports = {
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
entry: ['./src/main.js'],
output: {
path: path.join(__dirname, '/dist'),
publicPath: 'dist/',
filename: 'build.js'
},
module: {
loaders: [
{test: /\.vue$/,loader: 'vue'},
{test: /\.(png|jpg|gif)$/,loader: 'file?name=[name].[ext]?[hash]'},
{test: /\.css$/,loader: 'style!css'},
{test: /\.eot/,loader : 'file?prefix=font/'},
{test: /\.woff/,loader : 'file?prefix=font/&limit=10000&mimetype=application/font-woff'},
{test: /\.ttf/, loader : 'file?prefix=font/'},
{test: /\.svg/, loader : 'file?prefix=font/'}
]
},
// example: if you wish to apply custom babel options
// instead of using vue-loader's default:
babel: {
presets: ['es2015', 'stage-0'],
plugins: ['transform-runtime']
}
}