__webpack_hmr:1 GET http://localhost:52099/__webpack_hmr 404 (Not Found)
__webpack_hmr:1 GET http://localhost:52099/__webpack_hmr 404 (Not Found)
__webpack_hmr:1 GET http://localhost:52099/__webpack_hmr 404 (Not Found)
__webpack_hmr:1 GET http://localhost:52099/__webpack_hmr 404 (Not Found)
__webpack_hmr:1 GET http://localhost:52099/__webpack_hmr 404 (Not Found)
__webpack_hmr:1 GET http://localhost:52099/__webpack_hmr 404 (Not Found)
我的webpack.config是这样的
var path = require('path')
var webpack = require('webpack')
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
entry:
{
home: './src/home.js',
list: './src/list.js',
},
output: {
path: path.resolve(__dirname, './wwwroot/js/dist'),
publicPath: '/js/dist/',
filename: '[name].js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
contentBase: path.join(__dirname, "/js/dist"),
overlay: true,
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new UglifyJsPlugin({ uglifyOptions: { warnings: false } }),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
package.json是这样的
{
"name": "test",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"aspnet-webpack": "^1.0.29",
"async": "^2.6.0",
"debug": "^3.1.0",
"has": "^1.0.1",
"portfinder": "^1.0.13",
"readdirp": "^2.1.0",
"schema-utils": "^0.4.3",
"vue": "^2.2.1",
"webpack-hot-middleware": "^2.18.0"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-preset-latest": "^6.0.0",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"uglifyjs-webpack-plugin": "^1.1.8",
"vue-loader": "^11.1.4",
"vue-router": "^2.4.0",
"vue-template-compiler": "^2.2.1",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.11.1"
}
}
在asp.net core 1.1版本项目这样配置没问题,在asp.net core 2.0这样配置就报这样的错,不明白
参考 Webpack hmr: __webpack_hmr 404 not found:
Fixed by deleting the following line under entry:
'webpack-hot-middleware/client?path=http://'+hostname+':'+port+'/__webpack_hmr'
. I don't know why it worked.
看了这个,不是这个原因,没用的
@a2502971:
试试 Error when using HMR with ASP.NET CORE 2.0 中的方法,在 Startup 中添加 WebpackDevMiddleware
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true,
HotModuleReplacementEndpoint = "/dist/__webpack_hmr"
});