Giter Club home page Giter Club logo

estatico-nou's Introduction

lerna

Estático Nou

Refactored https://github.com/unic/estatico with separate packages for every task. Mono-repo based on Lerna.

What is this?

Estático is basically a set of (mostly) gulp.js tasks to build a static frontend. At Unic we use it to develop frontend prototypes / pattern libraries.

The goal is to provide a thin wrapper on top of de-facto-standards like webpack, Babel, Sass, ESLint or stylelint, to name the most important ones.

As you can see in our boilerplate, we rely on the default configuration files for aforementioned tools, which should make your code very portable. Specifically, you could decide on using webpack without our wrapper task and would still get the same result. However, using the tasks will give you the following advantages:

  • Sensible and battle-tested defaults for tools like webpack and Sass.
  • "Smart" file watching based on a dependency graph of your code. This makes sure that editing a Sass or Handlebars partial will only rebuild the necessary files.
  • Extended logging, making use of gulp's loglevel flag. So running a task with -LLLL will give you more detailed infos than with -L.
  • Config validation using joi, trying to make sure that you know why a task might be failing instead of just throwing an exception.

When could I use this?

It very much depends on what you are creating. We often build rather static frontend prototypes containing only small application parts. There, a setup based on Gulp task has proven to be very helpful and flexible.

If the asset pipeline part isn't that important, a static site generator like 11ty might be a better fit. It is also possible to combine Estático with tools like Fractal, which would take care of the templating and component previewing part.

For a JavaScript application we would rather recommend using the corresponding tools like Vue CLI, Create React App or Angular CLI.

How can I use it?

The tasks and helpers are npm packages published in our @unic scope. The READMEs explaining how to install and use them are both available on npmjs.com and in the corresponding directories of this repo (see links above).

The estatico-boilerplate package is meant as a demo project / boilerplate. Therefore it is not available on npm but rather needs to be cloned locally (see instructions on how to do this).

What does it contain?

Tasks

Helpers

How can I contribute?

  • Clone this repository
  • Install yarn if you don't already have it: npm i -g yarn
  • Bootstrap (installing dependencies and linking them): yarn bootstrap,
  • To remove node_modules from each package: yarn clean

If bootstrapping fails, reducing the concurrency might help: lerna bootstrap --concurrency=1

Every package in packages/ can be developed separately.

Manage npm dependencies

Since lerna does magic things with packages (symlinking local ones etc.), we need to use lerna add to add new dependencies to a package. Examples: lerna add node-sass --scope=@unic/estatico-sass or lerna add left-pad --dev --scope=@unic/estatico-boilerplate.

To remove dependencies, delete them from the corresponding package.json.

Run lerna bootstrap after any change (either adding or removing).

Boilerplate

As described above, the estatico-boilerplate package is meant as a demo project. I has the main packages specified as dependencies and Lerna takes care of linking them locally. So a change to estatico-stylelint will immediately be available in estatico-boilerplate. This is very useful when working on task packages since the corresponding changes can immediately be tested in the boilerplate.

Tests

To run all tests in every package we can call lerna exec -- npm test. For a specific one we can use lerna exec --scope=@unic/estatico-stylelint -- npm test (or npm run lerna-test after navigating into a package).

Release

npm release will run lerna publish --conventional-commits and generate a CHANGELOG via Conventional Changelog. For this changelog to be properly created, the correct commit message format needs to be used.

estatico-nou's People

Contributors

backflip avatar lbsonley avatar orioltf avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

estatico-nou's Issues

Add Travis CI

  • Set up config, possibly testing multiple Node versions

[boilerplate] CSS architecture

  • Remove usage of parent selector: .slideshow__slide {} over .slideshow { &__slide {} } (way easier to find and source maps are more stable) → evaluate sass-lint and stylelint to do this automatically
  • Evaluate combination of BEM and SMACSS/ITCSS for better structure / prefices @tobiasfrei

Rename "master" branch to "main"

Let's get rid of all master-slave terminology #BlackLivesMatter

More details on how and why we want this change https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx

Updating local clones

If someone has a local clone, then can update their locals like this:

$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch --unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main

Changing target branch for open PRs according to https://stackoverflow.com/a/24159161/3768943

Document CI usage

  • html task has a new clone option which will generate both dev and prod versions in one go

[stylelint] Update config

  • Configure Stylelint to work with Airbnb's CSS styleguide
  • Update boilerplate source code accordingly

Testing

  • Use in ongoing projects by replacing old tasks
  • Add basic tests where missing and reasonable

BUGS TO FIX:

  • Fix dependencyGraph to handle partials nesting themselves
  • Find solution for changing module template
  • Start watcher even when skipping build

Logging / debugging

  • Check each package for reasonable debugging info
  • Add debug logs if necessary
  • Evaluate a switch to gulplog since it should already work gulp-cli's different logging levels. This should allow us to use npm run gulp html -- -LLLL instead of $ NODE_DEBUG=estatico-handlebars-extended npm run gulp html, e.g. → #20

Publish on npm

  • Figure out and document how to release with Lerna
  • Publish

introduce pre-commit hook

{
  "husky": {
    "hooks": {
      "pre-commit": "yarn lint"
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

Document changes and reasoning

  • Maintainability (separation of concerns, replacement of custom approaches with de-factorstandards etc.)
  • Flexibility (use only the tasks/helpers you want)
  • Performance: ~50% speed improvement for initial build (boilerplate), ~90% speed improvement for incremental html rebuilds (large project), e.g.

[boilerplate] JS architecture

  • Establish the new way of writing JavaScript in collaboration with other Frontend Developers.
  • Restructure the whole Estatico JS initiation logic into separate NPM packages.
  • Add a more reusable way of writing JS (factory/composition).
  • Give a good documentation on what changed in the architecture and how developers can adapt.
  • Establish a checklist for JS Modules/Factories/Composites
  • Establish backward-compatibility for at least IE(X)

Factory/Composition

Examples

Generators

TODO

  • Use Apache license, Unic is the author
  • Make a workshop and discuss the proposition of factory/composition

Components

Notes

  • Enable better debugging inside of Modules/Components Better debugging?
  • Proper automatic documentation of components (JSdoc)
    https://github.com/jsdoc3/jsdoc

Extract tasks into separate packages

Tasks

Examples:

Criteria:

[utils] Remove dependency on estatico-watch

Reasons:

  • It is a circular dependency
  • Installing estatico-scaffold, e.g., relies on estatico-utils but definitely doesn't care about estatico-watch

Solution: Pass watcher as argument instead

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.