小编Gar*_*JMU的帖子

使用 webpack 为 react-lottie 从主包中排除 JSON 文件

在我们的 Web 应用程序中,我们有一些 JSON 文件,每个文件约 10-80k 行。这些已包含在我们的主要捆绑包中。这些由名为 react-lottie 的动画插件使用。

我们的一个例子 webpack.config.js

module.exports = {
  entry: ["./src/index.js"],
  module: {
    rules: [
      { test: /\.(js|jsx)$/, exclude: /node_modules/, use: ["babel-loader"] },
      {
        test: /\.(jpg|png|gif|ico)$/,
        use: {
          loader: "file-loader",
          options: { name: "[path][name].[hash].[ext]" }
        }
      }
    ]
  },
  resolve: { extensions: ["*", ".js", ".jsx"] },
  output: {
    path: __dirname + "/dist",
    publicPath: "/",
    filename: "[name].[hash].js"
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new HtmlWebpackPlugin({ hash: false, template: "src/index.html" }),
    new DashboardPlugin(),
    new CopyWebpackPlugin([
      {
        from: "src/components/Assets/BookingBar.js", …
Run Code Online (Sandbox Code Playgroud)

json reactjs webpack react-router

3
推荐指数
1
解决办法
3860
查看次数

标签 统计

json ×1

react-router ×1

reactjs ×1

webpack ×1