Coder Social home page Coder Social logo

webpack-tutorial's Introduction

Terminology

1-Entry point

An entry point for webpack is the starting point from which all the dependencies of a frontend project are collected. In practice, it's a simple JavaScript file.

2-Output

The output is where the resulting JavaScript and static files are collected during the build process. The default output folder for webpack is dist/, configurable as well.

3-Loaders

Loaders are third-party extensions that help webpack deal with various file extensions. For example there are loaders for CSS, for images, or for txt files.

The goal of a loader is to transform files in modules. Once the file becomes a module, webpack can use it as a dependency in your project.

4-Plugins

Plugins are third-party extensions that can alter how webpack works. For example there are plugins for extracting HTML, CSS, or for setting up environment variables.

5-Mode

webpack has two modes of operations: development and production.

Getting satrted:

mkdir webpack-tutorial && cd webpack-tutorial

npm init -y

Dependencies

npm i webpack webpack-cli webpack-dev-server --save-dev

To work with HTML in webpack we need to install a plugin, html-webpack-plugin

npm i html-webpack-plugin --save-dev

To work with CSS in webpack we need to install at least two loaders.

npm i css-loader style-loader --save-dev

To work with SASS in webpack we need to install at least the appropriate loaders.

Loaders here are necessary for helping webpack to understand how to deal with .scss files.

npm i css-loader style-loader sass-loader sass --save-dev

Working with modern JavaScript

webpack doesn't know on its own how to transform JavaScript code. This task is outsourced to a third-party loader, specifically babel-loader, with babel.

npm i @babel/core babel-loader @babel/preset-env --save-dev

Then configure babel by creating a new file, babel.config.json

touch webpack.config.js

webpack-tutorial's People

Contributors

bouabidi avatar

Watchers

 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.