vyushin / file-replace-loader

file-replace-loader is webpack loader that allows replace files in compile time
MIT License
11 stars 4 forks source link

Error: should have required property 'replacement' #18

Open kathom-universe opened 3 years ago

kathom-universe commented 3 years ago

When building for production using vue-cli-service build, the following error is thrown:

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Invalid options
  [options.]: should have required property 'replacement'
 undefined
    at PoolWorker.fromErrorObj (/app/core/frontend/node_modules/thread-loader/dist/WorkerPool.js:262:12)
    at /app/core/frontend/node_modules/thread-loader/dist/WorkerPool.js:204:29
    at mapSeries (/app/core/frontend/node_modules/neo-async/async.js:3624:14)
    at PoolWorker.onWorkerMessage (/app/core/frontend/node_modules/thread-loader/dist/WorkerPool.js:170:35)
    at validate (/app/core/frontend/node_modules/file-replace-loader/node_modules/schema-utils/dist/validate.js:98:11)
    at Object._default (/app/core/frontend/node_modules/file-replace-loader/dist/index.js:164:30)

It works when using the vue-cli-service serve command.

Webpack chain is used for building the webpack configuration. The vue inspect command returns the following configuration for the file-replace-loader:

{
  enforce: 'pre',
  test: /\.*$/,
  use: [
    {
      loader: 'file-replace-loader',
      options: {
        condition: 'always',
        replacement: function () { /* omitted long function */ },
        async: false
      }
    }
  ]
}
vyushin commented 3 years ago

@KathomDev , could you please send a link to full example of your case? And instruction how to reproduce this case.

kathom-universe commented 3 years ago

@KathomDev , could you please send a link to full example of your case? And instruction how to reproduce this case.

I will do that in the following days.

kathom-universe commented 3 years ago

Here is an example: https://github.com/KathomDev/vue-file-replace.

npm: 6.14.8 node: 14.15.0

Project was created with @vue/cli 4.5.9

kathom-universe commented 3 years ago

@vyushin Were you able to reproduce the issue?

vyushin commented 3 years ago

@vyushin Were you able to reproduce the issue?

Unfortunately this will possible for me not early than 25th January. Anyway, PR welcome.