text-transform-loader

2.0.0 • Public • Published

Text Transform Loader

Build Status

Webpack loader to prepend, append, or otherwise modify the text content of a module

You can use this for things like injecting headers or footers into your modules BEFORE any other loaders do their processing. For example, say you want to prepend all of your .scss files with the same @import function. You can do that!

This version supports webpack 2.x! If you try it and run into problems, check out the webpack 1.x release instead.

Installation

Via yarn:

yarn add --dev text-transform-loader

Via npm:

npm install --save-dev text-transform-loader

Configuration

Here are the things you can configure:

  • prependText: adds text to the top of the module
  • appendText: adds text to the bottom of the module
  • transformText: transforms the module by running the content and loader options through a custom function that returns the new content

Usage

Specify the loader and options in your webpack configuration:

{
  // ...
  module: {
    rules: [
      test: /\.s?css$/,
      use: {
        loader: 'text-transform-loader',
        options: {
          prependText: '@import \'your/stuff\';\n\n',
        }
      }
    ]
  },
  // ...
}

Readme

Keywords

Package Sidebar

Install

npm i text-transform-loader

Weekly Downloads

2,425

Version

2.0.0

License

MIT

Last publish

Collaborators

  • kmck