Skip to content
forked from bstaruk/starbase

⭐ webpack 3 boilerplate w/ babel (es6), eslint, postcss, cssnext, stylelint & more

License

Notifications You must be signed in to change notification settings

tothemun/starbase

 
 

Repository files navigation

starbase

Starbase is a Webpack 3, ES6 & PostCSS boilerplate that utilizes some of the juiciest open source tools around:

This boilerplate is intended to be small in scope so that it may be easily extended and customized, or used as a learning tool for folks who are trying to become familiar with Webpack 3.

license

Starbase is completely free, open source and public domain, so you are free to do whatever you wish with it -- commercially or personally. You can buy me a beer next time you're in Boston, star the project and tell a friend, or you can erase all signs of origin and tell your coworkers that you made it yourself. It's all good!

getting started

After completing the steps below, you will be ready to begin using Starbase:

  1. Install Node.js (latest LTS recommended)
  2. Install Yarn
  3. Clone Starbase into your project root directory
  4. Install dependencies by running yarn in your project root directory

Note: if you hate Yarn for some reason, you can skip Step 2 and use npm install instead of yarn in Step 4.

building, watching & developing

local development

Starbase uses webpack-dev-server to serve up your project at http://localhost:8080 for streamlined and convenient development.

After running npm run watch in the project root, your /src code will be served at the url above and watched for changes. As you modify code in /src, the project will be recompiled and your browser will refresh to show the latest changes.

cd /path/to/starbase
npm run watch

building for production

Use npm run build in your project root to run a production build.

Production builds compile & minify your assets into /dist for distribution and/or integration into whatever codebase you'll be using these assets in.

cd /path/to/starbase
npm run build

features you may want to remove

build-time cleanup

Starbase is setup to clear all contents of /dist (where compiled assets are piped into) during each npm run build. If you'd like to remove this part of the build process, perform the following steps:

  1. remove CleanWebpackPlugin from the plugins array in /webpack/webpack.config.prod.js
  2. remove CleanWebpackPlugin as a requirement at the top of /webpack/webpack.config.prod.js
  3. remove the CleanWebpackPlugin dependency from /package.json

Removing the cleanup process means that deleted assets in /src will not be deleted in /dist until you manually do so. I recommend keeping the cleanup process intact unless you have a specific reason not to, such as having un-managed assets in /dist.

fetch & promise polyfills

Because Starbase was built to accommodate ES6 & CommonJS (and not JQuery) it is assumed that you'll be using fetch for asynchronous requests.

Fetch is supported in all modern browsers, but some old dogs still don't support it and that's what we need the es6-promise & whatwg-fetch polyfills for.

If you want to remove these for any reason, perform the following steps:

  1. run yarn remove es6-promise whatwg-fetch in the project root to remove the dependencies
  2. remove the first few lines of /src/bundle.js (it'll be obvious which ones)

Note: if you think you might use fetch in the future, comment-out the includes instead of deleting them. Commented-out code is stripped out in production builds.

features you may want to customize

javascript & css linting

Starbase uses ESLint for Javascript (ES6) linting and stylelint for CSS linting. The configs (/.eslintrc and /.stylelintrc respectively) included out of the box contain some basic common rules. Modify them to your liking to encourage consistent code throughout your project.

airbnb eslint config

Starbase enforces the Airbnb JavaScript Style Guide with ESLint via eslint-config-airbnb. These rules are basically the industry standard in 2017 so I'd recommend adhering to them, but you can override individual rules via the project /.eslintrc file. I've included a couple basic overrides (in /.eslintrc) to demonstrate usage.

to remove the airbnb eslint config:
  1. in /.eslintrc, remove the line that says extends
  2. in /package.json, remove the eslint-config-airbnb dependency
  3. run yarn (or npm update if you hate yarn)

After completing the steps above, the only rules that eslint will enforce are the ones you define in the rules object in /.eslintrc.

features you may want to know about

global css variables

Starbase supports global CSS variables via the :root pseudo-element, which can be found in /src/variables/variables.css. You can split your variables into multiple files, and just import them into /src/variables/variables.css if you'd like them to be more granular.

These variables automatically injected into any CSS in the /src/components and /src/app directories, so they are always available for use in your app & component stylesheets.

Each component that comes with Starbase uses at least one variable to demonstrate the functionality.

All variables are cleaned up in your production code and only the values will remain, so there is no bloat or downside to using these variables. Go nuts!

About

⭐ webpack 3 boilerplate w/ babel (es6), eslint, postcss, cssnext, stylelint & more

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 79.5%
  • CSS 15.3%
  • HTML 5.2%