-
Notifications
You must be signed in to change notification settings - Fork 80
Resources: Setting up a basic Webpack project
Tags: #webdev, #javascript, #tools, #beginners
Creating a Webpack project doesn't have to be complex. This guide will take you through the steps of setting up a simple Webpack project, covering all essential configurations.
Ensure Node.js and npm are installed. Verify this by running the following commands in your terminal:
node -v
npm -v
Open a terminal, create a new directory, navigate into it, and initiate a Node.js project.
mkdir webpack-simple-project
cd webpack-simple-project
npm init -y
Install Webpack and the Webpack CLI as dev dependencies.
npm install --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin nodemon
Create a webpack.config.js
file in your project root. Add the following code:
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};
This file directs Webpack on how to bundle your assets.
Modify your package.json to include a build script:
"scripts": {
"build": "webpack --config webpack.config.js"
}
To run the build, execute:
npm run build
After running the build script, a bundle.js
file should appear in the dist folder. This is your bundled code.
Webcrumbs is Wordpress for React. And we need your support! Make sure to ⭐️ the repository and spread the word.
![](https://github.com/webcrumbs-community/webcrumbs/raw/main/src/img/logo.png)
- Home
- Architecture
- Manifesto
- Motivation
- Uniqueness
- FAQ
- Have any questions?
- What is WebCrumbs?
- Why WebCrumbs?
- How does WebCrumbs work?
- Library vs Plugin
- Components vs Plugin
- Browser Extensions vs Plugin
- How can the community contribute?
- What are the next steps with WebCrumbs?
- Is it another CMS?
- Why now?
- WordPress works with React?
- Examples of WebCrumbs Plugins
- WebCrumbs vs. the world