webpack loaders and include

前端 未结 3 1503
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 22:02

I\'m new to webpack and I\'m trying to understand loaders as well as its properties such as test, loader, include etc.

Here is a sample snippet of webpack.config.js that

3条回答
  •  旧时难觅i
    2021-02-06 22:43

    In webpack config there are multiple things for configuration, important ones are

    1. entry - can be an array or an object defining the entry point for the asset you want to bundle, can be a js as test here says do it only for /.js$. Your application if has multiple entry points use an array.
    2. include - defines the set of path or files where the imported files will be transformed by the loader.
    3. exclude is self explanatory (do not transform file from these places).
    4. output - the final bundle you want to create. if you specify for example

      output: { filename: "[name].bundle.js", vendor: "react" }

      Then your application js files will be bundled as main.bundle.js and react in a vendor.js files. It is an error if you do not use both in html page.

    Hope it helped

提交回复
热议问题