Skip to content
take control over output encoding of webpack assets
Branch: master
Clone or download
Latest commit 030d1af Mar 13, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Add .editorconfig Feb 27, 2019
.gitignore fix: updated testsetup Mar 10, 2019
.npmrc version config Mar 13, 2019
.travis.yml ci: travis init Mar 10, 2019
EncodingPlugin.js remove logging Mar 13, 2019
LICENSE licence added Nov 13, 2015
package.json version config Mar 13, 2019

Build Status

Webpack Encoding Plugin

Take control over the encoding of emitted webpack assets. This can be useful, if the delivering webserver enforces a specific content-type, so that your js-code is not interpreted as utf-8 by the browser.


install module

npm install webpack-encoding-plugin

setup webpack config

const EncodingPlugin = require('webpack-encoding-plugin');
module.exports = {
    entry: './entry.js',
    output: {
        path: '../dist',
        filename: 'bundle.js'
    plugins: [new EncodingPlugin({
        encoding: 'iso-8859-1'

Additional options:

test, include, exclude RegExp or array of RegExps to filter processed files (default test is /(\.js|\.css)($|\?)/i)


The Plugin uses iconv-lite to handle the encoding. A list of supported encodings can be found here


To use non-utf-8 encoding with webpack-dev-server, you must set the appropriate charset like so:

devServer:  {
   headers: {
      'Access-Control-Allow-Origin': '*',
      'Content-Type': 'application/javascript; charset=windows-1251'
   // ...
You can’t perform that action at this time.