赋予代码灵魂 , 追求极致性能

Hey guys, Here is Vtrois's Blog !

create-react-app 如何创建多个入口页面网站

  1. 主要是修改wepack的entry结点,增加多个webpack的入口:
entry: {
    index: [
      require.resolve('react-dev-utils/webpackHotDevClient'),
      require.resolve('./polyfills'),
      require.resolve('react-error-overlay'),
      paths.appIndexJs,
    ],
    admin:[
      require.resolve('react-dev-utils/webpackHotDevClient'),
      require.resolve('./polyfills'),
      require.resolve('react-error-overlay'),
      paths.appSrc + "/admin.js",
      ]
  },
  output: {
    path: paths.appBuild,
    pathinfo: true,
    filename: 'static/js/[name].bundle.js',
    chunkFilename: 'static/js/[name].chunk.js',
    publicPath: publicPath,
    devtoolModuleFilenameTemplate: info =>
      path.resolve(info.absoluteResourcePath),
  },

但同时也要配合:
2. HtmlWebpackPlugin配合修改
3. webpack Dev Server也要修改重定向。

点赞

发表评论

电子邮件地址不会被公开。