webpack-encoding-plugin
Control Webpacks output encoding
Last updated 9 years ago by quackes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install webpack-encoding-plugin 
SYNC missed versions from official npm registry.

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.

Usage

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)

Encodings

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

webpack-dev-server

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'
   }
   // ...
}

Current Tags

  • 0.3.1                                ...           latest (7 years ago)

6 Versions

  • 0.3.1                                ...           7 years ago
  • 0.3.0                                ...           7 years ago
  • 0.2.1                                ...           9 years ago
  • 0.2.0                                ...           10 years ago
  • 0.0.2                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 6
Last Month 2
Dependencies (3)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |