mica-core

1.3.1 • Public • Published

mica

Mica is a tool, alongside granite, to quickly build independent packages, components and publish to NPM without extensive boilerplate or build scripts.

Getting started

Create new project and run npm init to populate normal details. npm init

Now install Mica, along with some peer dependencies npm install --save-dev mica-core babel-core babel-loader babel-preset-es2015

To configure Mica you need to create a mica.config.js file in your project.

The minimum setup for this file:

export default {
  name: 'mica-core',
  library: 'mica'
};

The name will be the module name used when other use your package import mica from 'mica-core'; in this example. Library will be a global added when loading into browsers.

You can also add a .babelrc and customise your transpile options, as normal. For example for react:

.babelrc

{
  "presets": [
    "es2015",
    "react"
  ]
}

mica.config.js:

import { babel } from 'mica-core/lib/webpack';

export default {
  name: 'mica-headings',
  library: 'micaHeadings',
  webpack: babel({})
};

Currently there is only one webpack "block" but the intention is to move to the great webpack-blocks package once its Webpack 2.0 is stable.

Writing code

This library is slightly opinated in order to reduce complexity. The entry point to your app is lib/index.js and the module path is dest/{name-from-mica-config}.js

You can add this to your package.json:

{
  "main": "dist/mica-headings.js",
  "module": "lib/index.js",
  ...
}

You can now create and start adding code to lib/index.js, once you are happy you can run ./node_modules/.bin/mica This will compile your code into dest/{name-from-mica-config}.js which you can run from node if you want to.

Scripts + Deployment

To speed development up you can add scripts to your package.json

{
  "scripts": {
    "start": "mica",
    "build": "mica",
    "prepublish": "npm run build",
    "install": "npm run build"
  },
  ...
}

When your package gets installed now it will create the dist folder. This will also make publishing to NPM very easy.

Examples

Please see the example components in this repo in the packages folder for full examples.

Lerna

The best use of this package comes when using Lerna to keep multiple packages in the same repo and interconnected. See the format of this repository as an example.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.3.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.3.1
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i mica-core

Weekly Downloads

0

Version

1.3.1

License

MIT

Last publish

Collaborators

  • stephenwf