能否仅在浏览器中成功运行react-admin?

时间:2018-09-17 19:09:40

标签: react-admin

我想知道是否可以使用webpack成功构建react-admin以在浏览器中运行?我是npm / react / etc的新手,我只是不能追逐一堆随机线索,因为这很复杂。这是我为package.json准备的东西:

{
  "name": "new-admin",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "prop-types": "^15.6.2",
    "ra-data-json-server": "^2.3.1",
    "react": "^16.5.1",
    "react-admin": "^2.3.1",
    "react-dom": "^16.5.1",
    "react-scripts": "1.1.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "@babel/cli": "^7.0.0",
    "@babel/core": "^7.0.1",
    "@babel/node": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.2",
    "css-loader": "^1.0.0",
    "style-loader": "^0.23.0"
  }
}

这就是我要webpack.config.js所拥有的东西:

const path = require('path');

module.exports = {
    entry: './src/index.js',
    target: 'web',
    devtool: 'inline-source-map',
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-react']
                    }
                }
            },
            {
                test:/\.css$/,
                use:['style-loader','css-loader']
            }
        ]
    }
};

它可以很好地编译,但是当我尝试在浏览器中运行时,我会得到

enter image description here

html几乎是示例html,但是加载了main.js

0 个答案:

没有答案