Socket
Socket
Sign inDemoInstall

webpack-file-preprocessor-plugin

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    webpack-file-preprocessor-plugin

A lightweight yet generic webpack plugin for pre-processing assets before emitting.


Version published
Weekly downloads
197
increased by5.35%
Maintainers
1
Install size
16.3 kB
Created
Weekly downloads
 

Changelog

Source

0.0.2 (2019-10-28)

Closed Issues

Changes

* This Change Log was automatically generated by github_changelog_generator

Readme

Source

Webpack File Preprocessor Plugin

NPM Version NPM Downloads Travis Build Code Coverage NPM license PRs

A lightweight yet generic webpack plugin for pre-processing assets before emitting.

Installation

# Using npm
$ npm install webpack-file-preprocessor-plugin --save-dev

# Using Yarn
$ yarn add webpack-file-preprocessor-plugin --dev

Usage

This example demonstrates how to use this plugin to minify the html assets loaded using file-loader.

const WebpackFilePreprocessorPlugin = require('webpack-file-preprocessor-plugin');
const minifyHtml = require('html-minifier').minify;

module.exports = {
  entry: {
    app: './index.js'
  },
  output: {
    path: './public/dist',
    publicPath: '/dist/',
    filename: '[name].bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.html$/,
        use: {
          loader: 'file-loader',
          options: {
            name: 'tmpl/[hash].html'
          }
        }
      }
    ]
  },
  plugins: [
    new WebpackFilePreprocessorPlugin({
      // Prints processed assets if set to true (default: false)
      debug: true,
      // RegExp pattern to filter assets for pre-processing.
      pattern: /\.html$/,
      // Do your processing in this process function.
      process: source => minifyHtml(source.toString())
    })
  ]
};

Examples

  1. HTML Minifier - A simple example of minifying raw HTML files before they're emitted using this plugin.
  2. JS Minifier - A simple example of minifying javascript files before they're emitted using this plugin.

Changelog

Check the CHANGELOG for release history.

License

Licensed under MIT.

Keywords

FAQs

Last updated on 28 Oct 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc