Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
feat: chunks (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau authored Mar 13, 2017
1 parent 73bff30 commit 576f547
Show file tree
Hide file tree
Showing 10 changed files with 4,695 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/build/webpack.config.server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BannerPlugin, DefinePlugin } from 'webpack';
import { optimize, BannerPlugin, DefinePlugin } from 'webpack';
import mergeWith from 'lodash.mergewith';
import fs from 'fs';
import { config, createBabelLoader, createResolveConfigLoader } from './webpack.config.common';
Expand Down Expand Up @@ -60,6 +60,7 @@ export default function serverConfig(options) {
],
},
plugins: [
new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
options.dev && new BannerPlugin({
banner: 'require("source-map-support").install({ environment: \'node\' });',
raw: true,
Expand Down
2 changes: 2 additions & 0 deletions examples/chunks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/public
3 changes: 3 additions & 0 deletions examples/chunks/.vitaminrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"routes": "./routes"
}
8 changes: 8 additions & 0 deletions examples/chunks/modules/home.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Link } from 'vitaminjs/react-router';

export default () => (
<div>
<Link to="/module1">module 1</Link>
<Link to="/module2">module 2</Link>
</div>
);
1 change: 1 addition & 0 deletions examples/chunks/modules/module1.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => <div>module 1</div>;
1 change: 1 addition & 0 deletions examples/chunks/modules/module2.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => <div>module 2</div>;
19 changes: 19 additions & 0 deletions examples/chunks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "vitamin-entries-and-chunks-example",
"version": "1.0.0",
"scripts": {
"build": "vitamin build",
"start": "vitamin start",
"serve": "vitamin serve"
},
"author": "Christophe Hurpeau <christophe@evaneos.com>",
"repository": {
"type": "git",
"url": "https://github.com/evaneos/vitamin.git"
},
"license": "MIT",
"dependencies": {
"react": "^15.1.0",
"vitaminjs": "file:../.."
}
}
11 changes: 11 additions & 0 deletions examples/chunks/routes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Route } from 'vitaminjs/react-router';

const getComponent = getModule => (nextState, cb) => getModule().then(module => cb(null, module.default));

export default (
<Route>
<Route path="/" getComponent={getComponent(() => import('./modules/home'))} />
<Route path="/module1" getComponent={getComponent(() => import('./modules/module1'))} />
<Route path="/module2" getComponent={getComponent(() => import('./modules/module2'))} />
</Route>
);
Loading

0 comments on commit 576f547

Please sign in to comment.