webpack忽略反应懒惰导入

时间:2019-08-29 12:35:15

标签: reactjs webpack lazy-loading

Webpack仅生成index.js,没有任何块

反应文件16.9

const Price = lazy(() => import(/* webpackChunkName: "Price" */'../Price/Price'));

webpack配置4.39

module.exports = {
  entry: [`${__dirname}/index.js`],
  output: {
    path: `${__dirname}/dist`,
    publicPath: '/material/dist/',
    chunkFilename: '[name].index.js',
  },
  module: {
    rules: [
      { test: /\.js?$/, use: 'babel-loader', exclude: /node_modules/ },
      { test: /\.css$/, use: ['style-loader', 'css-loader'] },
      { test: /\.mjs$/, include: /node_modules/, type: 'javascript/auto' },
    ],
  },
  node: {
    fs: 'empty',
  },
};

在.babelrc中

    "@babel/plugin-syntax-dynamic-import",

但是,即使没有插件,仍然没有错误。

就像webpack一样,它无法识别任何延迟加载

0 个答案:

没有答案
相关问题