Skip to content

Webpack plugin to emit files. The only one that does it right.

License

Notifications You must be signed in to change notification settings

RTVision/emit-file-webpack-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emit file plugin for Webpack

npm: emit-file-webpack-plugin License

Webpack plugin to emit files. The only one that does it right.

Installation

  • With npm:
npm i --save-dev emit-file-webpack-plugin
  • With yarn:
yarn add --dev emit-file-webpack-plugin

Usage

webpack.config.js

const webpack = require('webpack');
const EmitFilePlugin = require('emit-file-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        new EmitFilePlugin({
            // OPTIONAL: defaults to the Webpack output path.
            // Output path.
            // Can be relative (to Webpack output path) or absolute.
            path: `.`,

            // REQUIRED.
            // Name of the file to add to assets.
            // if hash option is enabled add [hash] here to choose where to insert the compilation hash
            // see the hash option for more information
            filename: `index.js`,

            // REQUIRED.
            // File content. Can be either a string, a buffer, or a (asynchronous) function.
            // If the resulting object is not a string or a buffer, it will be converted to JSON.
            content: `console.log('Hello world!');`,

            // OPTIONAL: defaults to the webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL.
            // Asset processing stage.
            // https://webpack.js.org/api/compilation-hooks/#processassets
            stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,

            // OPTIONAL
            // Adds the compilation hash to the filename. You can either choose within the filename
            // where the hash is inserted by adding [hash] i.e. test.[hash].js or the hash will be
            // appended to the end of the file i.e. test.js?hash
            hash: false
        })
    ]
};

About

Webpack plugin to emit files. The only one that does it right.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%