🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

encoding-plugin

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

encoding-plugin

Control Webpack output encoding

1.1.3
Source
npm
Version published
Weekly downloads
271
65.24%
Maintainers
2
Weekly downloads
 
Created
Source

Webpack Encoding Plugin

Greenkeeper badge CircleCI

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 package

npm install encoding-plugin

Setup webpack config

const EncodingPlugin = require('encoding-plugin');
module.exports = {
  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'
   }
   // ...
}

Keywords

webpack

FAQs

Package last updated on 15 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts