Israel-Laguan / configuring-webpack-examples

Repository with example configuration in diferent use cases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contributors Forks Stargazers Issues-open Issues-closed


Logo

Webpack setup: One JS output

Learn by example how to setup a webpack web project
πŸ–ŠοΈ Read the article 🐞 Report a Bug πŸ™‹β€β™‚οΈ Request Feature

The Project

Repository with example configuration in diferent use cases

Features

  • Basic VanillaJS app with a single script or few commands
  • npm and node for javascript code
  • webpack for bundling

Prerequisites

  • npm 6.14 +
  • node 12.16 +
  • A Text Editor like VSCode

Getting Started

First step is to create a folder, then inside we initialize npm:

npm init -y

Init

npm i -D webpack webpack-cli

If you will only need one output JS file the only remaining thing to make is a folder called src/ and inside a file called index.js. Inside of this file you can put you code, call other files and import CSS. Now please open your file called package.json and in the section called "scripts" like this:

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack"
  },

All that code will be output into a new file inside dist/ folder just using this command npm start. You'll notice the new folder and a file called main.js will be produced.

npm start

This file have already minified and uglyfy code, ready for copy/paste in your HTML!

πŸ‘¨ Author

🀝 Contributing

Contributions, issues and feature requests are welcome! Feel free to check the issues page.

πŸ€— Show your support

Give a ⭐️ if you like this project!

πŸ“ License

This project is licensed under the MIT
Feel free to fork this project and improve it

About

Repository with example configuration in diferent use cases

License:MIT License


Languages

Language:JavaScript 100.0%