Skip to content

Commit

Permalink
add ui to NPM package
Browse files Browse the repository at this point in the history
  • Loading branch information
darthfiddler committed Jan 29, 2018
1 parent ad72185 commit e315b9e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 35 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
"dist/server.js",
"dist/client.js",
"dist/core.js",
"dist/ui.js",
"server.js",
"client.js",
"core.js"
"core.js",
"ui.js"
],
"keywords": [
"react",
Expand Down Expand Up @@ -123,7 +125,8 @@
"exportAliases": {
"client": "./dist/client.js",
"server": "./dist/server.js",
"core": "./dist/core.js"
"core": "./dist/core.js",
"ui": "./dist/ui.js"
}
},
"jest": {
Expand Down
8 changes: 8 additions & 0 deletions packages/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import Client from '../src/client/client.js';
import Game from '../src/core/game.js';
import { Flow, FlowWithPhases } from '../src/core/flow.js';
import { TurnOrder, Pass } from '../src/core/turn-order.js';
import Token from '../src/ui/token.js';
import { Card } from '../src/ui/card.js';
import { Grid } from '../src/ui/grid.js';
import { HexGrid } from '../src/ui/hex.js';

export default {
Client,
Expand All @@ -18,4 +22,8 @@ export default {
FlowWithPhases,
TurnOrder,
Pass,
Card,
Token,
Grid,
HexGrid,
};
8 changes: 4 additions & 4 deletions packages/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* https://opensource.org/licenses/MIT.
*/

import { Grid } from '../src/ui/grid.js';
import Token from '../src/ui/token.js';
import { Card } from '../src/ui/card.js';
import { HexGrid, Hex } from '../src/ui/hex.js';
import Token from '../src/ui/token.js';
import { Grid } from '../src/ui/grid.js';
import { HexGrid } from '../src/ui/hex.js';

export { Grid, Token, Card, HexGrid, Hex };
export { Grid, Token, Card, HexGrid };
70 changes: 41 additions & 29 deletions rollup.npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* https://opensource.org/licenses/MIT.
*/

import resolve from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import uglify from 'rollup-plugin-uglify'
import postcss from 'rollup-plugin-postcss'
import filesize from 'rollup-plugin-filesize'
import { minify } from 'uglify-es'
import pkg from './package.json'
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import postcss from 'rollup-plugin-postcss';
import filesize from 'rollup-plugin-filesize';
import { minify } from 'uglify-es';
import pkg from './package.json';

const env = process.env.NODE_ENV
const env = process.env.NODE_ENV;

const plugins = [
postcss(),
Expand All @@ -43,8 +43,8 @@ export default [

{
input: 'packages/client.js',
external: [ 'react' ],
globals: { 'react': 'React' },
external: ['react'],
globals: { react: 'React' },
output: { file: 'dist/client.js', format: 'umd' },
name: 'Client',
plugins: plugins,
Expand All @@ -57,42 +57,54 @@ export default [
plugins: plugins,
},

{
input: 'packages/ui.js',
external: ['react'],
globals: { react: 'React' },
output: { file: 'dist/ui.js', format: 'umd' },
name: 'UI',
plugins: plugins,
},

// UMD and ES versions.
{
input: 'packages/main.js',
external: [ 'react' ],
globals: { 'react': 'React' },
external: ['react'],
globals: { react: 'React' },
output: [
{ file: pkg.main, format: 'umd', name: 'BoardgameIO'},
{ file: pkg.module, format: 'es' }
{ file: pkg.main, format: 'umd', name: 'BoardgameIO' },
{ file: pkg.module, format: 'es' },
],
plugins: plugins.concat([
replace({ 'process.env.NODE_ENV': JSON.stringify(env) })
replace({ 'process.env.NODE_ENV': JSON.stringify(env) }),
]),
},

// Browser minified version.
{
input: 'packages/main.js',
external: [ 'react' ],
globals: { 'react': 'React' },
external: ['react'],
globals: { react: 'React' },
output: [
{ file: pkg.unpkg, format: 'umd' },
{ file: 'docs/react/boardgameio.min.js', format: 'umd' },
],
name: 'BoardgameIO',
plugins: plugins.concat([
replace({
'process.env.NODE_ENV': JSON.stringify('production')
'process.env.NODE_ENV': JSON.stringify('production'),
}),
uglify({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false
}
}, minify),
uglify(
{
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false,
},
},
minify
),
]),
}
},
];

1 comment on commit e315b9e

@nicolodavis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#93

Please sign in to comment.