babel-plugin-mickey-model-loader v0.3.9
babel-plugin-mickey-model-loader
Inject a model loader function into mickey with hmr support.
Install
npm install babel-plugin-mickey-model-loader redbox-react@1.x --save-devUsage
Add the following section in your .babelrc:
{
"plugins": ["mickey-model-loader", { loaderOptions: { directory: './models' } }]
}Load models:
import React from 'react';
import createApp from 'mickey';
import SomeComponent from './SomeComponent';
const app = createApp({
historyMode: 'hash',
});
app.load(); // default load all models from './models'
app.render(<SomeComponent />, document.getElementById('root'));app.load(pattern)
With this plugin, a handily method load(pattern) will be injected into app.
This method will try to load models matched with pattern from loaderOptions.directory specified directory (e.g. ./models). The pattern is a glob pattern matched by minimatch.
Falsely pattern will load all models.
Options
disableHmrDisable any HMR. Default:falsedisableModelHmrDisable model HMR. Default:falsequietDon't output any log. Default:falseloaderOptionsOptions forapp.loader()and these options are same asrequire.context(directory, useSubdirectories, regExp)directoryThe directory to match within. Default:'./models'useSubdirectoriesA boolean flag to include or exclude subdirectories. Default:trueregExpA regular expression to match files against. Default:/^\.\//
Note: If process.env.NODE_ENV is 'production', will disable any HMR and do not output any log. This is useful for release building.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago