Code Monkey home page Code Monkey logo

vvw's Introduction

vvw

Vue via Webpack. A project seed.

Getting Started

Get this repository's latest content inside a new git repository using degit:

npx degit https://github.com/slacktracer/vvw.git --force

Create a .env file at root level (.). It will be ignored by git.

Add development environment variables as needed.

# stop and run npm start again after adding new environment variables

BASE_URL=https://api.example.com

Then npm i...

Then npm start!

What's inside?

Framework

Vue, Vuex and Vue-Router, the very basics for a non-trivial Vue web application.

Compiling and bundling/building

The Webpack module bundler uses the Babel compiler and the Vue framework loaders (and Babel uses the TypeScript preset) to allow us to use the latest and greatest JS/TS that will run in any browser of our choosing (.browserlistrc)!

Before every commit and npm run patch the TypeScript compiler type checks the code.

These tools are mostly configured by the following configuration files at root (.) level:

  • .babelrc

And by the following configuration files at source (the ./src folder) level:

  • .babelrc
  • tsconfig.json

Testing

The project is set up to look for unit tests inside __unit-tests__ folders and run them using Jest.

It is also set up to run end-to-end tests from the cypress/integration folder (the default) using Cypress.

These tools are mostly configured by the following configuration files at root (.) level:

  • cypress.json
  • jest.config.json

Code quality

On every commit code is type checked, formatted and linted using TypeScript, Prettier and ESLint They all run on staged files only using lint-staged on a pre-commit git hook set up with Husky.

These tools are mostly configured by the following configuration files at root (.) level:

  • .eslintignore
  • .eslintrc.json
  • .huskyrc.json
  • .lintstagedrc.json
  • .prettierignore
  • .prettierrc

And by the following configuration files at source (the ./src folder) level:

  • .eslintignore
  • .eslintrc.json

Finally, the .editorconfig file is there, at root (.) level, to make different code editors behave in the same consistent way in regards to details like indentation size etc.

It is supposed to work out of the box with WebStorm and there is a plugin for VS Code.

Some ESLint tweaks

The following eslint-plugin-vue rules were turned off because they conflict with Prettier.

The rationale is that overall code formatting/style consistency is preferable to following every Vue recommended style (though they are very sensible ๐Ÿ˜”). A solution to accommodate both does not seem to exist at the time of writing. ๐Ÿ˜ž ๐Ÿคทโ€โ™€๏ธ

The @typescript-eslint/no-unused-vars rule is set as an error instead of a warning (the default).

The rationale is that nobody likes stupid unused variables hanging around and making the code look silly and stuff... ๐Ÿ˜’

Run npm Run

These are (allegedly) the most important scripts inside package.json.

For developing

npm start

Starts everything in development mode.

For testing

npm test

Runs unit tests using jest.

npm run test:e2e

Runs e2e tests using Cypress in terminal mode (cypress run).

For push starting the CI/CD process

npm run patch

Updates the patch (SemVer) number, commits, tags and pushes it to the repository.

Other scripts

For checking

npm run type-check

Runs the TypeScript compiler to type check the code.

npm run format-check

Runs Prettier to check the code formatting.

npm run lint

Runs ESLint to... well, lint the code.

CI/CD using CircleCI

These variables should be set at project level:

AWS_ACCESS_KEY_ID

The AWS access key ID. Who would have guessed?

AWS_REGION

The AWS region. But, honestly, it is always the same. You know it.

AWS_SECRET_ACCESS_KEY

Pretty much the same thing as the first one, but this one is seeecret...

BUILDS_BUCKET:

The name of the bucket for all builds (staging, demo and production).

NODE_ENV:

It should be production. It's not related to the destination environment but the build mode.

STAGING_BUCKET

The name of the bucket where the latest staging files should be copied to after build.

STAGING_DIST_ID:

It will be used to create an invalidation on CloudFront after the latest staging files are copied to the staging bucket.

Setting variables for each environment in three easy steps!

  1. Add the project name to the package.json file:

{ "name": "some_project_name", "version": "1.0.0", ... }

  1. npm run config. It will create the .circleci/config.yml file.

  2. Create a context for each environment with variables like BASE_URL.

Naming contexts

Follow this pattern, [project_name]_ENV_[environment].

We should end up with something like this:

  • SOME_PROJECT_NAME_ENV_STAGING
  • SOME_PROJECT_NAME_ENV_DEMO
  • SOME_PROJECT_NAME_ENV_PRODUCTION

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.