frontendmasters webpack-plugins

2018-11-12  本文已影响0人  云峰yf

Tapable Plugin System

Compiler & Compilation

Resolver & Module Factories

Parser & Templates

Compiler Walkthrough

Plugin System Code Walkthrough

Creating a Webpack Plugin

class MyFirstWebpackPlugin {
    apply(compiler) {
        compiler.hooks.done.tapAsync("MyFirstWebpackPlugin", (stats, cb) => {
            const assetNames = [];
            for (let assetName in stats.compilation.assets) {
                assetNames.push(assetName);
            }
            console.log(assetNames.join("\n"));
            cb();
        });
        compiler.hooks.compilation.tap("MyFirstWebpackPlugin", (compilation, params) => {
            new MyFirstWebpackCompilationPlugin().apply(compilation);
        });
    }
}
class MyFirstWebpackCompilationPlugin {
    apply(compilation) {
        compilation.hooks.seal.tap("MyFirstWebpackPlugin", () => {
            debugger;
        });
    }   
}
module.exports = MyFirstWebpackPlugin; 

Plugin Instance Hooks

Isolating Plugins

Creating a Custom Loader

Configuring Babel for Webpack

Webpack Dev Kit & Wrap Up

留下了一个示例项目:Webpack Developer Kit

上一篇下一篇

猜你喜欢

热点阅读