我按照本教程在Webpack中将React公开为全局.该Expose
模块安装和我加入配置webpack.config.js文件模块加载.但是,它无法运行和React Developer Tools仍然无法访问.
这是我的webpack.config.js文件,第一个加载器是expose-react:
var path = require ('path'), webpack = require ('webpack'), htmlWebpackPlugin = require ('html-webpack-plugin'); const PATHS = { app : path.join (__dirname, 'app'), build : path.join (__dirname, 'build') }; module.exports = { entry : { main : PATHS.app + '/Main.jsx' }, output : { path : PATHS.build, filename : 'dressAphrodite.js' }, module : { loaders : [ { test : require.resolve ('react'), loader : 'expose?React' }, { test : /\.css$/, loaders : ['style', 'css'], include : PATHS.app }, { test : /\.js?$/, loader : 'babel-loader', include : PATHS.app }, { test : /\.jsx?$/, loader : 'babel-loader', include : PATHS.app } ] }, debug : true, devtool : 'source-map', devServer : { contentBase : './app', progress : true, stats : 'errors-only', }, plugins : [ new htmlWebpackPlugin ({ title : 'Dress', hash : true }) ] };
只是为了安装依赖项的信息,这是我的package.json文件:
{ "name": "dress", "version": "1.0.0", "description": "", "main": "./main.jsx", "dependencies": { "i": "^0.3.3", "npm": "^3.5.2", "react": "^0.14.3", "react-dom": "^0.14.3" }, "devDependencies": { "babel-core": "^6.3.26", "babel-loader": "^6.2.0", "babel-polyfill": "^6.3.14", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", "css-loader": "^0.23.1", "expose-loader": "^0.7.1", "html-webpack-plugin": "^1.7.0", "style-loader": "^0.13.0", "webpack": "^1.12.9", "webpack-dev-server": "^1.14.0" }, "scripts": { "start": "webpack-dev-server" }, "author": "", "license": "ISC" }
这是.babelrc文件内容:
{ 'presets' : [ 'es2015', 'react' ] }
Franco Risso.. 10
实际上有一个解决方案,你必须在这里使用--inline选项启动webpack ,所以服务器将位于localhost:8080而不是localhost:8080/webpack-dev-server,热重载仍然可以工作你将能够看到你的反应工具:D
实际上有一个解决方案,你必须在这里使用--inline选项启动webpack ,所以服务器将位于localhost:8080而不是localhost:8080/webpack-dev-server,热重载仍然可以工作你将能够看到你的反应工具:D
我也有同样的问题.但是,devtools常见问题解答目前指出"目前iframe和Chrome应用/扩展程序无法检查",并且webpack在iframe中运行.