@ekomjah/imagecarousel
v1.0.0
Published
<<<<<<< HEAD
Readme
webpack-template
<<<<<<< HEAD
This is a minimal webpack template i have set up for ease of use of webpack and having a cheatsheet webpack.config.js file!
This is a minimal webpack template I have set up for ease of use of webpack and having a cheatsheet webpack.config.js file!
26887a68257db6cf7785fd1ce9507bf195c9643c
Here is the doc at your reach
How to use the Webpack bundler
If you haven't yet, install
npmfrom the official siteFirst run
npm init -yThis is for the purpose of installing the
package.jsonfile. So if you have the file, you can skip this step!Run
npm install -D webpack webpack-cli webpack-dev-server html-webpack-plugin style-loader css-loader html-loaderin any CLI of your choice (for installing the necessary devDependecies!)NOTE: For most basic SPAs (Single Page Applications), the above command is sufficient to load your
html,cssandwebpackdependencies.Feel free to remove any dependency that you may not be using to avoid loading unnecessary code and slowing the loading of your application!
To do this, run
npm uninstall package_nameThough optional, yet useful, consider using a code linter like ESLint. To use it, run:
npm init @eslint/config@latestand answer the questions that the terminal gives using your arrow keys! Then hitnpm install eslint@latest --save-devin the terminal as well!!To use a preset configuration, and then add some rules, to override, consider using a specific shared config that is hosted on npm. Such style guides like airbnb, standard, xo are the most used!
Then, run
npx webpackfor bundling the code and any other attached assets.
P.S.
html loaderis used to run anynon-JS, non-HTML type fileslike images wrapped inimgels.
If using images in JavaScript, default import the images like:
import <any_Name> from "./picture.extensionName"
- For a typical webpack project, the file structure should look like:
project/
|--src/
| |--index.js
| |--template.html
|--public/
| |--assets/
├───package.json
└───readme.md- Run
npm webpackto bundle the package; - Run
npm webpack serveto load the project in a browser environment on a local server. - For ease of use of these commands, add these to your scripts tag in your package.json file like so:
{
//some lines of code...
scripts: {
"build": "webpack",
"dev": "webpack serve",
//add the other existing lines in the scripts here...
},
//some other remaining lines of code...
}With this, you can then run
npm run devto view your project, load the project in a browser environment on a local server.Then run
npm run buildto bundle the code for deployment.
NOTE: When running these new commands, note that it is
npmthat is used and notnpxas was used before! Hence, it isnpm run devand notnpx run devas this will throw an error in your CLI.
- With this, your project should be ready for deployment.
- Consider using PaaS like Netlify, Vercel, Cloudflare or others to do this, as setting up pages could now become a rather complex task.
