webpack-memory2fs-plugin
Plugin that write memory files to harddist that generated by webpack when webpack-dev-server as backend
Install
npm install webpack-memory2fs-plugin -D
yarn add webpack-memory2fs-plugin -D
This is a webpack plugin that write memory file to harddist that generate by webpack, This is useful when we use webpack-dev-server proxy to backend service
Usage
webpack.config.js
const HtmlWebpackPlugin = const Memory2fs = moduleexports = entry: 'index.js' output: path: __dirname + '/dist' filename: 'index_bundle.js' plugins:
webpack.devserver.config.js
const webpack = const devServer = const wpConfigs = const compiler =
This will generate files dist/index_bundle.js, dist/index.html
nodejs with koa
var koa = var views = ; var app = // Must be used before any router is usedapp;
Options
mapfile
Create mapfile.json
to outputPath, all of file that Generated by webpack are recorded in this file
const Memory2fs = moduleexports = ...options plugins: mapfile: js: '.js' '.jsx' css: '.css' html: '.html'
exclude
Allows you to skip some file to write
{Array.} string is extname about file, like ['.html', '.js']
{RegExp}
const Memory2fs = moduleexports = ...options plugins: exclude: '.html' '.svg' // or exclude: /html/
outputPath
Allows you to specified the output root directory
const Memory2fs = moduleexports = ...options plugins: outputPath: path
extractTo
Allows you to extract files to specified directory that based on extension
The directory will be aoto created that it is a relative path offset your outputPath
or webpack outputPath
const Memory2fs = moduleexports = ...options plugins: extractTo: "html": '.html' '.hbs' "../myimages": '.jpg' '.svg'