babel-plugin-cortex-module
v1.0.0-beta.2
Published
babel plugin for cortex modules
Downloads
32
Readme
babel-plugin-cortex-module
babel plugin for import cortex module
Usage
Install
Install the plugin
npm i babel-plugin-cortex-module
Configuration
Define plugin in webpack.config.js
and add neurons/
as resolve path:
module.exports = {
module: {
loaders: [{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/, // Don't exclude 'neurons' here
query: {
presets: ['react', 'es2015'],
plugins: ["cortex-module"] // Define plugin here
}
}
},
resolve: {
modulesDirectories: ["node_modules", "neurons"] // Add 'neurons' here
}
}
Module Usage
Add @cortex
prefix to module name in your file:
var $ = require('@cortex/zepto');
// es2015 syntax also supported
import $ from '@cortex/zepto';
// requiring specific files
var something = require('@cortex/some-module/src/something');
Build
Run cortex install
and then webpack directly.
#!/usr/bin/env bash
cortex install
webpack