vue-cli-plugin-i18n icon indicating copy to clipboard operation
vue-cli-plugin-i18n copied to clipboard

json messages is empty when use pnpm

Open NateScarlet opened this issue 3 years ago • 5 comments

https://github.com/intlify/vue-cli-plugin-i18n/blob/fdc4fc04e1e9d3955907b47d9151f50d6530d2dc/index.js#L31

pnpm store package in a different way, so ../../src is not point to project src folder

vue inspect --rule i18n-resource

/* config.module.rule('i18n-resource') */
{
  test: /\.(json5?|ya?ml)$/,
  type: 'javascript/auto',
  include: [
    '${workspaceFolder}\\node_modules\\.pnpm\\[email protected]\\src\\locales'
  ],
  use: [
    /* config.module.rule('i18n-resource').use('i18n-resource') */
    {
      loader: '@intlify/vue-i18n-loader'
    }
  ]
}

NateScarlet avatar May 14 '21 11:05 NateScarlet

workaround:

    config.module
      .rule('i18n-resource')
      .include.clear()
      .add(resolve(__dirname, 'src/locales'));

i18n plugin should search nearest node_modules or use a different default value for pnpm

NateScarlet avatar May 17 '21 03:05 NateScarlet

Thank you for your reporting!

sorry, I don't usually use pnpm much, so I wasn't able to test it. I will fix this issue later.

kazupon avatar May 17 '21 14:05 kazupon

workaround:

    config.module
      .rule('i18n-resource')
      .include.clear()
      .add(resolve(__dirname, 'src/locales'));

i18n plugin should search nearest node_modules or use a different default value for pnpm

this issue and workaround help me a lot. Many vue project like vue3, vite has switch to pnpm now,

  • https://github.com/vuejs/core/pull/4766
  • https://github.com/vitejs/vite/pull/5060
  • https://github.com/intlify/vue-i18n-next/pull/731
  • https://github.com/vueuse/vueuse/commit/826351ba1d9c514e34426c85f3d69fb9875c7dd9

I hope this project will support pnpm with fix the wrong include in localeDir

Rhilip avatar Mar 15 '22 11:03 Rhilip

Hello, same pb with vue-cli. How can I fix this?

Silbad avatar Jun 17 '22 22:06 Silbad

ok I fixed it in the vue.config.js

    chainWebpack: config => {
        config.module
            .rule('i18n-resource')
            .include.clear()
            .add(path.resolve(__dirname, 'src/locales'));
    }

Thanks

Silbad avatar Jun 17 '22 22:06 Silbad