Giter Site home page Giter Site logo

styleguide-starterkit's Introduction

Styleguide starterkit

A starterkit to create web styleguides with Fractal and Webpack.

  • Fractal pre-configured with Nunjucks
  • JavaScript bundling with Webpack and Babel
  • Sass compilation, including Autoprefixer
  • SVG icons sprite generation
  • Live reload (with hot module replacement) for comfortable development
  • Automated release management with release-it

Installation

Prerequisites: Node.js >= 10, <= 12

Inside the directory of your choice, install a copy of the starterkit with:

curl -L https://github.com/liip/styleguide-starterkit/archive/master.tar.gz | tar zx --strip 1

Then install the npm dependencies with:

npm install

Getting started

To start the development server, run:

npm start

You can now access your styleguide at localhost:3000.

You’re all set, start to:

  • Create components as .nunj (Nunjucks) files inside the components directory
  • Write some style inside assets/scss/common.scss
  • Write JavaScript inside assets/scripts/common.js
  • Put some *.svg icons in the assets/icons directory
  • Write documentation as .md (Markdown) files inside the docs directory.

Build

You can build a static version of the styleguide to deploy it wherever you like by running:

npm run build

The generated files go to the dist directory.

Release

The starterkit comes with a preconfigured release management tool. It will automatically update the CHANGELOG.md file at the root of the project based on the commit messages as long as they follow the Angular commit guidelines. It will also bump the version number in the package.json, run the build command above, commit, tag and push the changes. This process is interactive and you’ll be able to skip steps manually if you like.

To release a new version run:

npm run release [patch|minor|major|version_number]

By default the version bump is automatically determined based on the commits messages.

Read more in the release-it documentation.

Deploy

To deploy a build of the styleguide, simply replace the blank command in the package.json, under scripts -> deploy. This will be automatically invoked at the end of the release process described above.

An example of a simple deploy command using rsync:

"deploy": "rsync -avz --delete --exclude='.*' dist/ [email protected]:/var/www/html/my-styleguide"

⚠️ Notice the --delete flag which means all files not present locally will be deleted on the remote server. Be careful, this can leads to data loss!

You can also deploy manually at any time by running:

npm run deploy

Misc

Browsers support

The browsers support is defined in .browserslistrc. It’s used both by Autoprefixer for the CSS and by @babel/preset-env for the JavaScript.

Check browserslist’s documentation to change the browser support.

Icons

Icons placed inside assets/icons are combined into a sprite called icons.svg when referenced. To load them, either reference them in your JavaScript:

import 'icons/foo.svg';

Or in your stylesheet:

background-image: url('../icons/foo.svg');

Webpack will automatically rewrite the links to the sprite with the correct identifier. See svg-sprite-loader documentation for more information.

You can then easily use an icon in a template with the icon snippet:

{% render '@icon', { id: 'foo', class: 'bar' } %}

Warning: This method of including remote SVG file is not supported by Internet Explorer 11 and below. You may want to polyfill it with svgxuse.

styleguide-starterkit's People

Contributors

ldgtd avatar lebenleben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

maikelgg

styleguide-starterkit's Issues

Support npm commands on windows with cross-env

There is a nice little helper called cross-env which provides Windows support for npm commands.

Example:

"build:webpack": "cross-env NODE_ENV=production webpack",

That alone doesn't help yet but it is a good starting point.

Doesn't generate SVG icon

I have a clean installation of styleguide-starterkit and paste a couple of svg icons (from https://feathericons.com). As far as I see it doesn't generate a svg sprite for me. No icons.svg is in my project.
When running fractal, both from npm start and a build version I get a 404 on icons.svg.

Release process

Could be great to integrate by default the new release process into the staterkit. What do you think ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.