2.0.3 • Published 8 years ago

grommet-toolbox v2.0.3

Weekly downloads
10
License
Apache-2.0
Repository
github
Last release
8 years ago

grommet-toolbox

Dependency Status devDependency Status

DEPRECATED: Please use grommet pack and grommet check available in the new grommet-cli

Developer Environment for Grommet applications with the following built-in features:

  • Ability to create a production ready distribution with minified JavaScript and CSS
  • Ability to sync your distribution to a remote location
  • JavaScript and Sass linters
  • Development server with hot-reloading
  • Test infrastructure based on tape and gulp watch
  • Code coverage using Istanbul
  • Convert raw svgs to Grommet icons with accessibility support
  • Bundle your project and its dependencies in a compressed file

grommet-toolbox runs on top of Gulp.

Install

npm install grommet-toolbox --save-dev

Basic usage

gulpfile.babel.js

import gulp from 'gulp';
import grommetToolbox from 'grommet-toolbox';

var opts = {
  copyAssets: [
    'src/index.html',
    {
      asset: 'src/img/**',
      dist: 'dist/img/'
    }
  ],
  scssAssets: ['src/scss/**/*.scss'],
  jsAssets: ['src/js/**/*.js'],
  mainJs: 'src/js/index.js',
  mainScss: 'src/scss/index.scss',
  devServerPort: 9000
};

grommetToolbox(gulp, opts);

Grommet-toolbox augments gulp object with these additional tasks:

  • gulp copy: uses copyAssets option to move files to distribution folder.
  • gulp generate-icons: uses icons option to convert raw svg icons to Grommet icons.
  • gulp scsslint: uses scssAssets option to lint your Sass code.
  • gulp jslint: uses jsAssets and testPaths options to lint your JavaScript code.
  • gulp dev: starts a webpack dev server with hot reloading. See options for example configuration.
    • --config: Set the path of the config file to use.
    • --no-preprocess: Skips preprocess tasks.
    • --no-open: Skips opening dev server url in a browser.
  • gulp dist: prepares your application/library for production.
    • --config: Set the path of the config file to use.
    • --no-preprocess: Skips preprocess tasks.
    • --no-minify: Skips minifying JS code.
  • gulp sync: uses sync option to sync distribution content to a remote server.
  • gulp test: uses testPaths option to execute tests based on Tape.
  • gulp test:watch: runs tests and watch for changes to execute the tests again.
  • gulp test:coverage: runs tests and generates a code coverage report.
  • gulp test:update: runs all the tests and updates the Jest snapshots for the project.
  • gulp pack: uses the package.json dependencies object to create a compressed file with all the dependencies included.

Recommended Usage

As your configuration grows it gets really difficult to manipulate everything inside a single gulp file. Grommet-toolbox offers a config file where you can store your application specific settings. This is the recommended way of using this tool. Now you will have two files, grommet-toolbox.config.js and gulpfile.babel.js:

grommet-toolbox.config.js

export default {
  copyAssets: [
    'src/index.html',
    {
      asset: 'src/img/**',
      dist: 'dist/img/'
    }
  ],
  scssAssets: ['src/scss/**/*.scss'],
  jsAssets: ['src/js/**/*.js'],
  mainJs: 'src/js/index.js',
  mainScss: 'src/scss/index.scss',
  devServerPort: 9000
};

gulpfile.babel.js

import gulp from 'gulp';
import grommetToolbox from 'grommet-toolbox';

grommetToolbox(gulp);

grommet-toolbox will look into your application's root folder and extract the configuration for your project.

Options

propertytypedescriptiondefaultexample
argvobjectOptional. Default cli args set on gulp tasks. See above.{}{open: false}
basestringOptional. Base working directoryprocess.cwd()base: '.'
copyAssetsarrayOptional. Assets to be copied to the distribution folderundefinedSee copyAssets WIKI
eslintConfigPathstringOptional. Path to your custom eslint config fileundefinedeslintConfigPath: path.resolve(__dirname, '../.eslintrc')
eslintOverridestringOptional. Path to your custom eslint overridesundefinedeslintOverride: path.resolve(__dirname, 'customEslintrc')
devPreprocessarrayOptional. A set of tasks to run before gulp devundefined['set-webpack-alias']
devServerDisableHotbooleanOptional. If true, will disable webpack hot reloadingfalsedevServerDisableHot: true
devServerHoststringOptional. Host address for the webpack dev server'localhost'devServerHost: '127.0.0.1'
devServerPortintOptional. Sets a listener port for the webpack dev server8080devServerPort: 9000
devServerProxyobjectOptional. Proxy requests from the webpack dev serverundefineddevServerProxy: { '/rest/*': 'http://localhost:8114' }
devServerobjectOptional. Any additional options for the webpack dev serverundefineddevServer: { https: true }
diststringOptional. Location of the distribution folder'dist'dist: 'distribution'
distPreprocessarrayOptional. A set of tasks to run before gulp distundefined['dist-css']
envobjectOptional. Adds environment variables for Nodeundefined{ DEV_MODE: 'true'}
iconsobjectOptional. Converts raw icons to a Grommet iconundefinedSee icon WIKI
jsAssetsarrayRequired. Location of your JavaScript Assets[]jsAssets: ['src/js/**/*.js']
jsLoaderobjectOptional. If you want to use another webpack loader for your JavaScript Assetsreact-loader{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /(node_modules|bower_components|src\/lib)/ }
lintCachebooleanOptional. If true, it will skip caching for linters (build time increases).truelintCache: false
mainJsstringRequired. Location of your main JavaScript fileundefinedmainJs: 'src/js/index.js'
preCommitTasksarrayOptional. The gulp tasks to run as git pre-commit hooksjslint, scsslint, test['jslint','scsslint','test']
publicPathstringOptional. Your main app context'/'publichPath: '/docs'
scssAssetsarrayOptional. Location of your Sass Assets[]scssAssets: ['src/scss/**/*.scss']
scssLoaderobjectOptional. If you want to use another webpack loader for your SCSS Assetsreact-loader{ test: /\.scss?$/, loader: 'file?name=assets/css/[name].css!sass'}
scsslintboolean(deprecated) Optional. If false, it will skip Sass lintingtruescsslint: false
syncobjectOptional. Syncs your content to a remote serverundefinedsync: { hostname: 'grommet.io', username: 'grommet', remoteDestination: '/var/www/html/'}
testPathsarrayOptional. Location of your test assetsundefinedtestPaths: ['test/**/*.js']
webpackobjectOptional. Additional webpack options to be used in gulp distundefinedSee Webpack Configuration
webpackProfilestringOptional. Location to save webpack profile stats in json format.undefinedwebpackProfile: './stats.json'

Example

See grommet-todo

Advanced

See Advanced Usage wiki

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.4.5

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.7

9 years ago

0.3.6

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.12

9 years ago

0.2.11

9 years ago

0.2.10

9 years ago

0.2.9

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.27

9 years ago

0.1.26

9 years ago

0.1.25

9 years ago

0.1.24

9 years ago

0.1.23

9 years ago

0.1.22

9 years ago

0.1.21

9 years ago

0.1.20

9 years ago

0.1.19

9 years ago

0.1.18

9 years ago

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

10 years ago

0.1.13

10 years ago

0.1.12

10 years ago

0.1.11

10 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago