Skip to content

YoshiyukiKato/webpack-iconv-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpack-iconv-plugin

Webpack plugin to change encoding of output. This plugin depends on node-iconv.

Usage

//webpack.config.js
const WebpackIconvPlugin = require("webpack-iconv-plugin");

module.exports = {
  //...your webpack config
  plugins: [
    new WebpackIconvPlugin("UTF-8", "SHIFT-JIS", "TRANSLIT", { "\\\\" : "¥" })
  ]
};

WebpackIconvPlugin(from, to, whenUntranslatable, preReplaceMap)

from/to

Encoding of input and output. See here to know supported encordings.

whenUntranslatable

How to deal with an input including untranslatable chars. See here to know available settings.

  • TRANSLIT
  • IGNORE

preReplaceMap

Correspondence table of chars to replace before translation.
For instance, in case of converting from UTF-8 to SHIFT-JIS, \ could not be translated. To escape characters, SHIFT-JIS uses ¥ instead of \.
We want to replace \ as ¥ before translation of iconv. In this case, we pass a map of chars:

{
  "\\\\" : "¥"
}

LICENSE

MIT

About

Webpack plugin to change encoding of output files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published