首页 新闻 搜索 专区 学院

asp.net core +vue.js 项目 运行老报这样的错?

0
[待解决问题]

__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这样配置就报这样的错,不明白

a2502971的主页 a2502971 | 菜鸟二级 | 园豆:204
提问于:2018-02-01 11:49
< >
分享
所有回答(1)
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.

dudu | 园豆:38247 (高人七级) | 2018-02-01 17:07

看了这个,不是这个原因,没用的

 

支持(0) 反对(0) a2502971 | 园豆:204 (菜鸟二级) | 2018-02-02 08:55

@a2502971:
试试 Error when using HMR with ASP.NET CORE 2.0 中的方法,在 Startup 中添加 WebpackDevMiddleware

app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
    HotModuleReplacement = true,
    HotModuleReplacementEndpoint = "/dist/__webpack_hmr"
});
支持(0) 反对(0) dudu | 园豆:38247 (高人七级) | 2018-02-09 12:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册