GithubHelp home page GithubHelp logo

kitsonk / cli-build-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dojo/cli-build-app

0.0 3.0 0.0 2.73 MB

Command for building Dojo 2 applications

License: Other

JavaScript 47.91% TypeScript 0.94% HTML 51.11% CSS 0.04%

cli-build-app's Introduction

@dojo/cli-build-app

Build Status Build status codecov npm version

The official CLI command for building Dojo 2 applications.

WARNING This is currently alpha software. This is not yet production ready, so you should use at your own risk.

Usage

To use @dojo/cli-build-app in a single project, install the package:

npm install @dojo/cli-build-app

Features

@dojo/cli-build-app is an optional command for the @dojo/cli.

Building

There are three modes available to build a Dojo 2 application, dist, dev and test. The mode required can be passed using the --mode flag:

dojo build app --mode dist

The built application files are written to the output/{mode selected} directory

Note: dist is the default mode and so can be run without any arguments, dojo build app.

Dist Mode

The dist mode creates a production ready build.

Dev mode

The dev mode creates an application build that has been optimized for debugging and development.

Test mode

The test mode creates bundles that can be used to run the unit and functional tests of the application.

Serving the Application

A web server can be started with the --serve flag. By default, the application is served on port 9999, but this can be changed with the --port (-p) flag:

dojo build -s -p 3000 # serve the app on port 3000

Watching

Building with the --watch option observes the file system for changes, and recompiles to the appropriate output/{dist|dev|test} directory, depending on the current --mode. When used in the conjunction with the --serve option and --mode=dev, --watch=memory can be specified to enable automatic browser updates and hot module replacement (HMR).

dojo build -w # start a file-based watch
dojo build -s -w=memory -m=dev # build to an in-memory file system with HMR

Eject

Ejecting @dojo/cli-build-app will produce the following files under the config/build-app directory:

  • build-options.json: the build-specific config options removed from the .dojorc
  • ejected.config.js: the root webpack config that passes the build options to the appropriate mode-specific config based on the --env.mode flag's value.
  • base.config.js: a common configuration used by the mode-specific configs.
  • dev.config.js: the configuration used during development.
  • dist.config.js: the production configuration.
  • test.config.js: the configuration used when running tests.

As already noted, the dojorc's build-app options are moved to config/build-app/build-options.json after ejecting. Further, the modes are specified using webpack's env flag (e.g., --env.mode=dev), defaulting to dist. You can run a build using webpack with:

node_modules/.bin/webpack --config=config/build-app/ejected.config.js --env.mode={dev|dist|test}

Configuration

Applications use a .dojorc file at the project root to control various aspects of development such as testing and building. This file, if provided, MUST be valid JSON, and the following options can be used beneath the "build-app" key:

bundles: object

Useful for breaking an application into smaller bundles, the bundles option is a map of webpack bundle names to arrays of modules that should be bundled together. For example, with the following configuration both src/Foo and src/Bar will be grouped in the foo.[hash].js bundle:

{
	"build-app": {
		"bundles": {
			"foo": [
				"src/Foo",
				"src/Bar"
			]
		}
	}
}

cldrPaths: string[]

An array of paths to CLDR JSON files. Used in conjunction with the locale and supportedLocales options (see below). If a path contains the string {locale}, that file will be loaded for each locale listed in the locale and supportedLocales properties. For example, with the following configuration the numbers.json file will be loaded for the "en", "es", and "fr" locales:

{
	"build-app": {
		"locale": "en",
		"supportedLocales": [ "es", "fr" ]
		"cldrPaths": [
			"cldr-data/main/{locale}/numbers.json"
		]
	}
}

features: object

A map of has features to boolean flags that can be used when building in dist mode to remove unneeded imports or conditional branches. See the static-build-loader documentation for more information.

locale: string

The default locale for the application. When the application loads, the root locale is set to the user's locale if it supported (see below), or to the default locale as a fallback.

pwa: object

A parent map that houses settings specific to creating progressive web applications.

pwa.manifest: object

Specifies information for a web app manifest. For example:

{
	"build-app": {
		"pwa": {
			"manifest": {
				"name": "Todo MVC",
				"description": "A simple to-do application created with Dojo 2"
			}
		}
	}
}

supportedLocales: string[]

An array of supported locales beyond the default. When the application loads, the user's locale is checked against the list of supported locales. If the user's locale is compatible with the supported locales, then the user's locale is used throughout the application. Otherwise, the default locale is used. For example, with the following configuration the application locale will be set to Pashto or Arabic if either is listed as the user's locale, with Farsi used as the default.

Example:

{
	"build-app": {
		"locale": "fa",
		"supportedLocales": [ "ps", "ar" ],
		"compression": "gzip",
		"bundles": {
			"widgets": [
				"src/widgets/Header",
				"src/widgets/Footer"
			]
		}
	}
}

How do I contribute?

We appreciate your interest! Please see the Dojo 2 Meta Repository for the Contributing Guidelines. This repository uses prettier for code style and is configured with a pre-commit hook to automatically fix formatting issues on staged .ts files before performing the commit.

Installation

To start working with this package, clone the repository and run npm install.

In order to build the project run grunt dev or grunt dist.

Scripts

test

Builds a new test artifact from the repository source code and re-installs the test-app dependencies before running all unit and functional tests.

build-test-artifact

Builds and packages cli-build-app as dojo-cli-build-app.tgz in the dist directory.

generate-fixtures

Re-generates the test fixtures in test-app. Assumes that the dependencies have been installed for the test app.

prettier

Runs prettier on all .ts files in the src and tests directories, this will fix any detected code style violations.

Testing

Test cases MUST be written using Intern using the BDD test interface and Assert assertion interface.

90% branch coverage MUST be provided for all code submitted to this repository, as reported by istanbul’s combined coverage results for all supported platforms.

The command is tested by running via the Dojo CLI and asserting the build output against known fixtures. To do this, a test artifact needs to be built and installed into the test-app:

npm test

Once the test artifact has been installed, if there have been no changes to the command code grunt test can be used to repeat the tests.

Licensing information

© 2017 JS Foundation. New BSD license.

cli-build-app's People

Contributors

agubler avatar

Watchers

 avatar  avatar  avatar

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.