blueprints
blueprints copied to clipboard
Module for Nuxt.js to create distributable micro-apps
@nuxt/blueprints
Module for Nuxt.js to create distributable micro-apps
:construction: WIP
This module is considered experimental and a work-in-progress.
Examples
Check the example for a simple blueprint example.
If you are looking for a more advanced example, have a look at the NuxtPress repository which is also build using blueprints.
Node v12.4 required
If you wish to run the example from this repo, you need to use at least Node v12.4.0 due to the use of static class features. Those are transpiled on release using @babel/plugin-proposal-class-properties, but the example runs from source.
Quick Docs
The blueprint module is a supercharged module container which supports autodiscovery of folders and resolving of templates/files.
Features:
- Define a template by adding the template identifiers
tmpl
ortemplate
to the name (the template identifier is removed before Nuxt.js will build the files) - Files which are not templates are just copied if needed (small performance improvement)
- Prefix template identifiers with a
$
to replace the identifier with the blueprint instanceid
(instead of removing the template identifier)
Main methods
-
autodiscover(<rootDir>, { validate(<path>), filter(<parsed path>) })
Filter and validate callbacks are more or less the same,validate
runs during walking the fs and receives the full path as string argument .Filter
runs when the fs walking has finished and passes the result ofpath.parse
as argument.
It returns the found files by type, where type is the name of the first level folder
-
resolveFiles(<files>, <pathPrefix>)
This method simply checks if a add<capitalize(type)>
method exists. Eg if you have a first level folder plugins
then it will call the addPlugins
method with the list of files. If the corresponding method doesnt exists then its assumed it are just generic files (or templates) which need to be copied.
The pathPrefix
argument is the folder in buildDir
into which the files will be copied (i.e. if you set this to 'my-id' then all the blueprint files/templates are copied into .nuxt/my-id
)
It returns a mapping of the src
to dst
for all files
Development
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Start development server using
npm run dev
License
MIT License
Copyright (c) Nuxt.js Team