Giter VIP home page Giter VIP logo

webpack-loader's Introduction

webpack-loader

webpack中loader自定义,配置学习

loader配置

loader执行顺序

默认是从右到左,从下到上。

{
     test:/\.js$/,
     use:['loader3','loader2','loader1']
}

上面loader执行顺序就是loader1-loader2-loader3

{
    test:/\.js$/,
    use:'loader1'
},
{
    test:/\.js$/,
    use:'loader2'
},
{
    test:/\.js$/,
    use:'loader3'
}

上面loader执行顺序就是loader3-loader2-loader1

loader分类

(1)pre 在前面的loader
(2)post 在后面的loader
(3)normal 正常loader
(4)inline 行内loader

module:{
    rules:[
        {
            test:/\.js$/,
            use:'loader1',
            enforce:'pre'
        },
        {
            test:/\.js$/,
            use:'loader2'
        },
        {
            test:/\.js$/,
            use:'loader3',
            enforce:'post'
        }
    ]
}

上面loader执行顺序就是loader1-loader2-loader3
loader默认是由两部分组成,分别是pitch和normal。

loader特点

  1. 第一个loader要返回js脚本
  2. 每个loader只做一件事,为了使loader在更多场景链式调用
  3. 每一个loader都是一个模块
  4. 每个loader都是无状态的,确保loader在不同模块转换之间不保存状态

webpack-loader's People

Contributors

rocky-191 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.