gettext-html-plugin

Gettext html webpack plugin

Usage no npm install needed!

<script type="module">
  import gettextHtmlPlugin from 'https://cdn.skypack.dev/gettext-html-plugin';
</script>

README

Gettext Html Plugin

Install

npm install gettext-html-plugin --save-dev

Useage

webpack.config.js

const HtmlWebpackPlugin = require('html-webpack-plugin')
const GettextHtmlPlugin = require('gettext-html-plugin')

module.exports = {
  entry: {
    index: 'index.js'
  },
  output: {
    path: __dirname + '/dist',
    filename: 'index.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: __dirname + '/index.html',
      chunks: ['index']
    }),
    new HtmlWebpackPlugin({
      filename: 'zh-cn.html',
      template: __dirname + '/index.html',
      chunks: ['index']
    }),
    new GettextHtmlPlugin({
      langsPath: __dirname + '/langs',
      sources: {
        'zh-cn.html': 'zh_CN'
      }
    })
  ]
}