Skip to content

Commit

Permalink
Created a sample based on webpack->fusebox transition.
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0liQ committed Jun 5, 2017
1 parent df1cfad commit 0edf24d
Show file tree
Hide file tree
Showing 12 changed files with 4,647 additions and 72 deletions.
7 changes: 5 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const Modelkit = require('./lib/modelkit').default;
const modelkitConfig = require('./modelkit.config');
const randomConfig = require('./samples/random-files/modelkit.config');
const modelkitConfig = require('./samples/modelkit/modelkit.config');

const modelkit = new Modelkit();
modelkit.run(modelkitConfig);
modelkit.run(randomConfig);
modelkit.run(modelkitConfig);
34 changes: 34 additions & 0 deletions samples/modelkit/fuse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { FuseBox, BabelPlugin } = require('fuse-box'); // eslint-disable-line import/no-extraneous-dependencies

const isProduction = process.env.NODE_ENV === 'production';

const fuse = FuseBox.init({
globals: { modelkit: '*' },
package: {
name: 'modelkit',
entry: 'src/index.js',
},
homeDir: 'src',
output: 'lib/$name.js',
plugins: [
BabelPlugin({
config: {
sourceMaps: true,
presets: ['env'],
plugins: [
'lodash',
],
},
}),
],
});

const bundle = fuse.bundle('modelkit')
.instructions('>[index.js]')
.sourceMaps(true);

if (!isProduction) {
bundle.watch();
}

fuse.run();
816 changes: 816 additions & 0 deletions samples/modelkit/modelkit.config.js

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions samples/modelkit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "modelkit",
"version": "0.0.2",
"main": "lib/modelkit.js",
"module": "src/index.js",
"author": "Li0liQ <[email protected]>",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-plugin-lodash": "^3.2.11",
"babel-preset-env": "^1.4.0",
"cross-env": "^4.0.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.1.3",
"eslint-plugin-import": "^2.2.0",
"lodash-webpack-plugin": "^0.11.3",
"rimraf": "^2.6.1",
"webpack": "^2.5.1",
"webpack-node-externals": "^1.6.0"
},
"dependencies": {
"escape-string-regexp": "^1.0.5",
"grasp": "^0.5.0",
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"yarn": "^0.23.4"
},
"scripts": {
"dev": "webpack --progress --colors --watch",
"build": "cross-env NODE_ENV=production webpack",
"lint": "eslint ./src",
"clean": "rimraf ./output"
},
"repository": {
"type": "git",
"url": "https://github.com/Li0liQ/modelkit"
},
"keywords": [
"config",
"feature",
"flag"
],
"bugs": {
"url": "https://github.com/Li0liQ/modelkit/issues"
},
"homepage": "https://github.com/Li0liQ/modelkit"
}
50 changes: 50 additions & 0 deletions samples/modelkit/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const webpack = require('webpack');
const path = require('path');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const libraryName = 'modelkit';
const outputFile = libraryName + '.js';

const config = {
entry: __dirname + '/src/index.js',
devtool: 'source-map',
output: {
path: __dirname + '/lib',
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: ['lodash'],
}
}
}]
},
plugins: [
new webpack.ContextReplacementPlugin(
/node_modules[\/\\]grasp/,
path.resolve(__dirname, 'node_modules'),
{
'grasp-equery': 'grasp-equery',
'grasp-squery': 'grasp-squery',
'acorn': 'acorn',
}
),
new LodashModuleReplacementPlugin({
'collections': true,
'flattening': true,
}),
],
target: 'node',
externals: [nodeExternals()]
};

module.exports = config;
Loading

0 comments on commit 0edf24d

Please sign in to comment.