0

这就是我试图让 webpack 复制locales项目根级别文件夹中的 JSON 文件的方式。

  config.plugins.push(
    new CopyPlugin({
      patterns: [
        {
          from: "./locales",
          to: "./",
        },
      ],
    }),
    new webpack.DefinePlugin({
      "process.env.NODE_ENV": JSON.stringify(
        (env && env.NODE_ENV) || "production"
      ),
    })
  );

我收到以下错误

D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\webpack\bin\webpack.js:348
                        throw err;
                        ^

TypeError: Cannot read property 'thisCompilation' of undefined
    at CopyPlugin.apply (D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\copy-webpack-plugin\dist\index.js:457:20)
    at Compiler.apply (D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\tapable\lib\Tapable.js:375:16)
    at webpack (D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\webpack\lib\webpack.js:33:19)
    at processOptions (D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\webpack\bin\webpack.js:335:15)
    at D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\webpack\bin\webpack.js:397:2
    at Object.Yargs.self.parse (D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\webpack\node_modules\yargs\yargs.js:533:18)
    at Object.<anonymous> (D:\aakashverma\BVC\hello-ps-bvc-addon\addon\src\main\assets\node_modules\webpack\bin\webpack.js:152:7)

我清理并重新安装了 node_modules 但仍然没有进展。

请帮忙。

编辑:package.json在下面添加

  "dependencies": {
    "@material-ui/core": "^4.11.1",
    "@reduxjs/toolkit": "^1.4.0",
    "flatted": "^3.1.0",
    "gql-query-builder": "^3.5.0",
    "i18next": "^19.8.4",
    "i18next-http-backend": "^1.0.21",
    "ps-solution-library-ui-common": "^1.7.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-i18next": "^11.8.5",
    "react-redux": "^7.2.1",
    "react-resize-aware": "^2.7.2",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "redux": "^4.0.5",
    "redux-form": "^8.3.6",
    "redux-form-validators": "^3.0.1"
  },
  "devDependencies": {
    "babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
    "babel-plugin-transform-es3-property-literals": "^6.22.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "copyfiles": "^2.4.1",
    "html-webpack-externals-plugin": "^3.8.0",
    "ps-solution-library-webpack-common": "^1.0.2",
    "uglifyjs-webpack-plugin": "^2.2.0"
  },
4

0 回答 0