Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

memfs-webpack

Example of how to use memfs with webpack.

Basically you need to add an alias like this:

 alias: {'fs': 'memfs',}

to your webpack.config.js:

module.exports={devtool: 'inline-source-map',entry: './index.js',output: {filename: 'bundle.js'},resolve: {extensions: ['.js'],alias: {'fs': 'memfs',}},module: {loaders: [{test: /\.js$/,loader: 'babel-loader',query: {presets: ['es2015']}}]},};

Getting started with this example

gitclone https://github.com/streamich/memfs-webpackcdmemfs-webpacknpminstallnpmrunstart

Now open your browser and go to http://localhost:8080/index.html. Open dev console and you should see:

index.js:4 Hello world!
index.js:5 Object {/text.txt: "Hello world!"}

It is output from memfs, although in the code we used the actual fs module:

import{vol,writeFileSync,readFileSync}from'fs';writeFileSync('/text.txt','Hello world!');console.log(readFileSync('/text.txt','utf8'));console.log(vol.toJSON());

About

Example of how to use memfs with webpack

Resources

Stars

36 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages