Webpack应该摇树了吗?

时间:2018-11-21 15:14:02

标签: reactjs webpack babel

构建Webpack捆绑包时出现错误。我导入了一个React Spinup组件import { Spinup } from '../../react-website/dist/bundle.esm';,然后看到错误消息说webpack缺少与该包相关但与Spinup组件无关的加载器。我希望Webpack能够智能地仅获取Spinup导入的捆绑软件的部分及其导入(依此类推)。我想念什么?

webpack.config

const path = require('path');

module.exports = {
    entry:  './src/spinup.js',
    output: {
        filename: 'spinup.js',
        path: path.resolve(__dirname, 'dist')
    },
    // module: {
    //     rules: [
    //         { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
    //     ]
    // },
    mode: 'production',
};

package.json

"dependencies": {
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "webpack": "^4.26.0"
  },
  "devDependencies": {
    "@babel/core": "^7.1.6",
    "@babel/preset-env": "^7.1.6",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.4",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "path": "^0.12.7",
    "webpack-cli": "^3.1.2"
  },
  "sideEffects": false

0 个答案:

没有答案