我尝试使用我的React原生Android应用作为网站。我跟着这个tutorial
当我运行webpack-dev-server
时显示错误。
webpak.cofig.js
module.exports = {
entry: "./entry.js",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0', 'react']
}
}
]
},
resolve: {
alias: {
"react-native": "react-native-web"
}
}
};
entry.js
document.write(require('./../testreact/index.android.js'));
的package.json
{
"name": "testreact",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "adb reverse tcp:8081 tcp:8081 && node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"firebase": "^4.1.2",
"react": "^16.0.0-alpha.12",
"react-native": "0.45.1",
"react-native-router-flux": "^3.38.0",
"react-native-web": "0.0.104",
"react-navigation": "^1.0.0-beta.11",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.5.0"
},
"devDependencies": {
"autoprefixer": "^7.1.1",
"babel-core": "^6.25.0",
"babel-jest": "20.0.3",
"babel-loader": "^7.1.0",
"babel-preset-react-native": "2.0.0",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
更新
答案 0 :(得分:0)
如果尚未解决此问题,请在您的webpack config
文件中使用babel-loader
代替babel-core
。