README
memory-webpack-plugin
A webpack plugin for create memory assets
Install
- add package
$ yarn add memory-webpack-plugin
- edit
webpack.config.js
const MemoryWebpackPlugin = require('memory-webpack-plugin');
module.exports = {
...
plugins: [
...
new MemoryWebpackPlugin({
'abc.css': async () => '.app { display: flex; }'
})
]
};
import
in code;
import style from 'abc.css';
// do something;
console.log(style);
Usage
const MemoryWebpackPlugin = require('memory-webpack-plugin');
// MyPlugin
module.exports = class MyPlugin extends MemoryWebpackPlugin {
// init
constructor(data) {
super(data);
this.descriptor = { name: 'my-plugin' };
}
// apply
apply(compiler) {
super.apply(compiler);
// set memory
this.$set('abc.css', source);
// get memory
this.$get('abc.css');
// do something;
...
}
}