0.0.0-beta.1 • Published 9 months ago

i18n-verify-loader v0.0.0-beta.1

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

安装依赖

npm i i18n-verify-loader -D

配置 loader

在 configureWebpack 中配置 module.rules

{
  test: /\.vue$/, //其他类型的文件同理
  use: [
    {
      loader: '@geega/i18n-verify-loader',
      options: {
        fileType: 'vue', //解析vue文件需要加上该字段,其他类型的可不填
        i18nAlias: ['i18n.t', '$t'], // i18n函数名,已经国际化的数据需要过滤,不同项目可能存在不同名字的情况
        i18n_verify: true, //是否开启检查,只提取
        i18n_replace: true, //检查完以后是否替换字符
      }
    },
  ],
  include: [
    resolve(__dirname, 'src'), //指定目录
  ],
  exclude: [
    resolve(__dirname, 'src/locales'), //过滤本地国际化数据目录
    resolve(__dirname, 'node_modules'),//过滤node_modules
  ],
},

或者

chainWebpack: (config) => {
  config.module
    .rule("@geega/i18n-verify-loader")
    .test(/\.tsx$/)
    .include.add(resolve("./src/pages"))
    .end()
    .use("@geega/i18n-verify-loader")
    .loader("@geega/i18n-verify-loader")
    .options({
      fileType: 'vue', //解析vue文件需要加上该字段,其他类型的可不填
      i18nAlias: ['i18n.t', '$t'], // i18n函数名,已经国际化的数据需要过滤,不同项目可能存在不同名字的情况
      i18n_verify: true, //是否开启检查,只提取
      i18n_replace: true, //检查完以后是否替换字符
    })
    .end();
},