找到了一个解决方案,
webpack devserver用作IIS的反向代理。
NPM:
npm install --save react-hot-loader@nextnpm install webpack-dev-server --save-dev
webpack.config.js,IIS是运行IIS的代理:
var webpack = require('webpack');var path = require("path");var proxy = 'localhost:61299';module.exports = { entry: [ // activate HMR for React 'react-hot-loader/patch', // the entry point of our app './scripts/src/index.tsx', ], //entry: "./scripts/src/index.tsx", output: { filename: "./scripts/dist/bundle.js", }, // Enable sourcemaps for debugging webpack's output. devtool: "source-map", resolve: { // Add '.ts' and '.tsx' as resolvable extensions. extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"] }, module: { loaders: [ // All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'. //{ test: /.tsx?$/, loader: "ts-loader" } { test: /.tsx?$/, loader: ['react-hot-loader/webpack', 'ts-loader'] } ] }, plugins: [ new webpack.HotModuleReplacementPlugin(), // enable HMR globally new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates ], devServer: { proxy: { '*': { target: 'http://' + proxy, } }, port: 8080, host: '0.0.0.0', hot: true, },}然后,我可以使用以下命令从项目根文件夹启动Web服务器:
node_modules.binwebpack-dev-server。如果随后访问,
http://localhost:8080/我将进行热重装,并且仍然可以使用C#Web API,因为它将在“
http:// localhost:61299 / ”上代理IIS Express。



