npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wok-cli/preset-standard

v1.0.7

Published

Standard preset wok-cli

Downloads

14

Readme

@wok-cli/preset-standard

A standard preset with pre-configured common tasks for Wok.

Installation

This preset requires @wok-cli/core and gulp.

npm i gulp @wok-cli/core @wok-cli/preset-standard --save-dev

Usage

  1. Create a wok.config.js file in the root folder of your project with the following code:
module.exports = require('@wok-cli/preset-standard/config');
  1. Create a gulpfile.js in the root folder of your project with the following code:
const $ = require('@wok-cli/core');
const preset = require('@wok-cli/preset-standard');

const wok = preset($);

module.exports = wok.resolve();

Alternatively to point (1) you can reference the preset config in a wok property in your project's package.json:

{
  "name": "my-project",
  // ...
  "wok": "@wok-cli/preset-standard/config"
}

Environmental Defaults

This preset sets the following environmental options:

| parameter | value | description | | ---------- | ------ | --------------------------------------------- | | lint | true | lints JavaScript and CSS files on build | | sourcemaps | | writes external sourcemaps during development | | paths | | an object with path fragments |

Folder Structure

The paths object defines the expected folders structure as follows:

├─ application # sources root folder
│  ├─ assets
│  │  ├─ javascripts # JavaScript files
│  │  ├─ stylesheets # SASS files
│  ├─ vendors # 3rd party files not installed by any package manager
│  ├─ fixtures # Data files. May contain JSON, JS, Markdown, etc...
│  ├─ views # Nunjucks/HTML files
│  │  ├─ partials # View partials
│  │  ├─ templates # Nunjucks templates
│  │  ├─ *.njk # Views
├─ static # Files to be copied into `public` "as-is" like images, fonts, videos
├─ public # Build destination folder

Exposed tasks

bump

Implements @wok-cli/task-bump.

clean

Removes all files in the public folder.

copy

Copies files from the static folder into the public folder. Image files will be processed using @wok-cli/plugin-imagemin.

styles

Processes CSS and SCSS files in application/assets/stylesheets and outputs the results in public/assets/stylesheets. SCSS files are processed using @wok-cli/plugin-sass.

Files will be linted with gulp-stylelint before processing. Set the lint property to false to disable the linter.

Note: sass includePaths options is set by default to: ['application/vendors', 'node_modules'].

scripts

Processes JavaScript files in application/assets/javascripts and outputs the results in public/assets/javascripts. Files will be parsed using Babel. See below for configuration options.

Files will be linted with gulp-eslint before processing. Set the lint property to false to disable the linter.

modernizr

Generates a custom Modernizr build parsing JavaScript, CSS and SCSS files in the application/assets/javascripts and application/assets/stylesheets folders. The output build will be saved into the public/vendors/modernizr folder.

Implements @wok-cli/task-modernizr.

views

Processes view files in application/views and outputs the results into public.

This task implements the following modules:

Subfolders

You can create as many sub-folders in application/views as your project requires. Note that template is a reserved folder for extendable Nunjucks templates and partials should only be used for HTML/Nunjucks partials.

Files starting with _ will be ignored.

Nunjucks globals

The task will also parse JSON view data sources from application/fixtures/ and expose them to the Nunjucks templates as global objects.

It will also expose two additional global objects:

server

Runs a static server on localhost:8000 serving the public and static folder.

Implements @wok-cli/task-server.

watch

Watches files in application and static for changes, processes them and reloads the page.

CSS files trigger a live-reload (file injection) instead of a full reload.

You can customize the running watchers by tapping into the watchers hook. Hook functions receive an array as first argument. The array can contain:

  • a configuration object suitable for $.watcher
  • a custom function

Hook function also receive an object as 4th argument with the following properties:

| parameter | value | description | | --------- | ------ | --------------------------------------------------------------------------------- | | tasks | object | An object containing all the previously defined tasks (both normal and composed). | | params | object | The watch task params | | reload | task | Reload task | | stream | task | Reload stream task |

default

The default task (executed by running gulp on a terminal) will perform the following tasks:

  • clean
  • copy
  • styles
  • scripts
  • modernizr
  • views

For production builds, assets will be revised using @wok-cli/task-rev and scripts will be minified with gulp-minify.

serve

A shorthand task executing the following tasks: default, watch and server.

Note: when executed within serve the default task will not copy files from static to public.

Extending the configuration

The preset exposes a configuration function that returns an object that you can extend to customize it:

module.exports = (env) => {
  const presetConfig = require('@wok-cli/preset-standard/config')(env);

  return {
    ...presetConfig,
    // add your properties here
  };
};

Configuring Babel

This plugin comes with a default configuration for Babel based on @babel/preset-env and including @babel/plugin-proposal-class-properties.

@babel/preset-env is configured with the following options:

{
  modules: false,
  loose: true,
  useBuiltIns: false,
}

In order to use this configuration on your project create a .babelrc.js file in the root folder of your project and add the following content:

module.exports = require('@wok-cli/preset-standard/configs/babel');

Also remember to configure target browsers by adding a browserslist property to your project's package.json:

{
  // ...
  "browserslist": [
    ">= 1%",
    "last 1 Chrome version",
    "last 1 ChromeAndroid version",
    "last 1 Edge version",
    "last 1 Firefox version",
    "last 1 iOS version",
    "last 1 Safari version"
  ]
}