1.0.4 • Published 6 years ago
create-minimal-webpack-app v1.0.4
create-minimal-webpack-app
A minimal site generator using Webpack and friends.
Features
- HTML:: The
index.htmlfile is generated and automatically includes Webpack CSS/JS bundles using the HTML Webpack Plugin. It also can optionally include configured data passed down frompackage.json. - CSS: The CSS Loader allows you to
importCSS files in your JavaScript when needed. This CSS is compiled together and extracted to amain.cssfile by way of the Mini CSS Extract Plugin. - JavaScript: No need to worry about compatibility in browsers, your code will be transpiled from ES2015 into something they can understand. Webpack installs and configures Babel for you.
- Assets: The URL Loader is installed for loading image/font
assets as URLs, so you can use them in your JS/CSS with ease.
Additionally, the
public/directory is populated with favicons and other files that are served statically. - Linting: ESLint and Stylelint are automatically configured
with recommended JS/CSS settings, and some additional helper rules.
This can be found in the
package.jsonfor later editing. - Development: Webpack Dev Server is installed so you can get to coding right away. It automatically reloads modules that change, so you can see changes without needing to refresh.
- Deployment: The
yarn deploytask builds your app and deploys thedist/directory to Surge. It's meant as a starting point, but Surge is a great hosting provider so there's no shame in keeping the default! Just make sure you add a-d YOUR_DOMAINto the end so you don't get a random*.surge.shdomain each time you deploy.
Usage
With Yarn:
yarn create minimal-webpack-app your-app-nameWith NPM:
npm install create-minimal-webpack-app
create-minimal-webpack-app your-app-nameYou'll get an application directory with the following contents:
your-app-name
├── index.html
├── package.json
├── public
│ ├── android-chrome-192x192.png
│ ├── android-chrome-512x512.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── favicon.ico
│ └── site.webmanifest
├── src
│ ├── index.css
│ └── index.js
├── webpack.config.js
└── yarn.lock
2 directories, 12 filesThis will get you going with the bare minimum necessary to start developing.
Start the server by running:
yarn startTo run lint checks:
yarn lintYou can also build the application to dist/:
yarn buildOr, deploy to Surge using a random domain:
yarn deployNOTE: This will change domain names each time unless you pass a
-d your-original-domain.surge.sh the next time you deploy.
Configuration
To configure the title of the app, edit app.title from
package.json:
{
"app": {
"title": "Your App Name"
}
}You can use this object to pass additional configuration to your HTML:
{
"app": {
"title": "Your App Name",
"heading": "Hello World"
}
}Read it out using EJS tags:
<h1><%= htmlWebpackPlugin.options.heading %></h1>