Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Forces webpack-dev-server to write bundle files to the file system.

License

Notifications You must be signed in to change notification settings

BrightIT/write-file-webpack-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

write-file-webpack-plugin

NPM version js-canonical-style

Forces webpack-dev-server program to write bundle files to the file system.

This plugin has no effect when webpack program is used.

Install

npm install write-file-webpack-plugin --save-dev

API

/**
 * @typedef {Object} options
 * @property {RegExp} test A regular expression used to test if file should be written. When not present, all bundle will be written.
 * @property {boolean} useHashIndex Use hash index to write only files that have changed since the last iteration (default: true).
 * @property {boolean} log Logs names of the files that are being written (or skipped because they have not changed) (default: true).
 */

/**
 * @param {options} options
 * @returns {Object}
 */
new WriteFilePlugin();

new WriteFilePlugin({
    // Write only files that have ".css" extension.
    test: /\.css$/,
    useHashIndex: true
});

Usage

Configure webpack.config.js to use the write-file-webpack-plugin plugin.

You must add outputPath property to the devServer configuration (For explanation see gajus#1). devServer.outputPath value must be equal to output.path configuration value.

import path from 'path';
import WriteFilePlugin from 'write-file-webpack-plugin';

export default {
    devServer: {
        outputPath: path.join(__dirname, './dist')
    },
    output: {
        path: path.join(__dirname, './dist')
    },
    plugins: [
        new WriteFilePlugin()
    ],
    // ...
}

See ./sandbox for a working webpack configuration.

About

Forces webpack-dev-server to write bundle files to the file system.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%