intlify / vue-i18n-loader

:globe_with_meridians: vue-i18n loader for custom blocks
MIT License
267 stars 29 forks source link

feat: i18n custom block pre-compilation bundling #93

Closed kazupon closed 4 years ago

kazupon commented 4 years ago

We can bundle custom block resources with JavaScript by pre-compiling with vue-loader, similar to vue-template-compiler / @vue/compiler-sfc. We can improve the performance of our application. 💨

the following the pre-compiled custom block resources:

image

We need to configure webpack.config.js with using options like the below:

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      // ...
      {
        resourceQuery: /blockType=i18n/,
        type: 'javascript/auto',
        use: [
          {
            loader: '@intlify/vue-i18n-loader',
            options: {
              preCompile: true
            }
          }
        ]
      }
    ]
  },
  plugins: [new VueLoaderPlugin()]
}