Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Commit 96d88cf

Browse files
authored
Merge pull request #8 from cjdev/umd
Add UMD build
2 parents 0fd54f6 + dbf005d commit 96d88cf

6 files changed

Lines changed: 100 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
/node_modules
1+
/dist
22
/lib
3+
/node_modules
34
npm-debug.log

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
"name": "@cjdev/visual-stack",
33
"version": "0.7.6",
44
"files": [
5+
"dist",
56
"lib",
67
"src"
78
],
9+
"main": "lib/index.js",
810
"scripts": {
9-
"build": "gulp build",
10-
"clean": "rimraf lib",
11+
"build": "gulp build && npm run dist",
12+
"dist": "npm run dist:umd && npm run dist:min",
13+
"dist:umd": "NODE_ENV=dev webpack src/index.js dist/visual-stack.js",
14+
"dist:min": "NODE_ENV=production webpack src/index.js dist/visual-stack.min.js",
15+
"clean": "rimraf lib && rimraf dist",
1116
"lint": "eslint src test",
1217
"prepublish": "npm run clean && npm run lint && npm run build && npm run test",
1318
"test": "mocha --compilers js:babel-register,css:./test/utils/css-null-compiler --recursive test/components",
1419
"watch": "gulp watch"
1520
},
1621
"peerDependencies": {
17-
"css-loader": ">=0.23.1",
1822
"react": ">=0.14.7"
1923
},
2024
"dependencies": {
@@ -25,15 +29,17 @@
2529
"devDependencies": {
2630
"babel-cli": "^6.6.4",
2731
"babel-core": "^6.6.4",
32+
"babel-loader": "^6.2.5",
2833
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.4",
2934
"babel-plugin-transform-object-rest-spread": "^6.6.4",
3035
"babel-preset-es2015": "^6.6.0",
3136
"babel-preset-react": "^6.5.0",
3237
"babel-register": "^6.7.2",
33-
"css-loader": ">=0.23.1",
38+
"css-loader": "^0.25.0",
3439
"enzyme": "^2.1.0",
3540
"eslint": "^2.2.0",
3641
"eslint-plugin-react": "^4.1.0",
42+
"extract-text-webpack-plugin": "^1.0.1",
3743
"gulp": "^3.9.1",
3844
"gulp-babel": "^6.1.2",
3945
"gulp-filter": "^4.0.0",
@@ -43,6 +49,9 @@
4349
"react": "^0.14.7",
4450
"react-addons-test-utils": "^0.14.7",
4551
"react-dom": "^0.14.7",
46-
"rimraf": "^2.5.2"
52+
"rimraf": "^2.5.2",
53+
"style-loader": "^0.13.1",
54+
"url-loader": "^0.5.7",
55+
"webpack": "^1.13.2"
4756
}
4857
}

src/components/Form.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ export const Legend = ({ children, ...otherProps }) =>
2626
<legend {...otherProps}>{children}</legend>;
2727

2828
export const Form = ({ children, vertical, ...otherProps }) =>
29-
<form className={vertical ? "form-vertical" : "form-horizontal"} {...otherProps}>{children}</form>;
29+
<form className={vertical ? 'form-vertical' : 'form-horizontal'} {...otherProps}>{children}</form>;
3030

3131
export const FormGroup = ({ children, error, label, required, vertical }) =>
3232
<div className={`form-group ${error ? 'has-error' : ''}`}>
3333
{label ? <Label vertical={vertical} className={!vertical ? 'col-sm-3' : ''} required={required}>{label}</Label>
34-
: <div className={!vertical ? "col-sm-3" : ''} />}
34+
: <div className={!vertical ? 'col-sm-3' : ''} />}
3535
<div className={!vertical ? 'col-sm-5' : ''}>
3636
{children}
3737
</div>

src/components/Sidebar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import classNames from 'classnames';
22
import React, { PropTypes } from 'react';
33
import './Sidebar.css';
44

5-
export const NavItem = ({ label, grouped = false, expanded = false, linkTo }) => {
5+
export const NavItem = ({ label, grouped = false, expanded = false /* , linkTo */ }) => {
66
const classes = classNames({
77
indent: grouped,
88
collapse: grouped && !expanded,

src/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import './global';
2+
3+
// modules that do not need qualification. i.e., the components
4+
// they export can be scoped to VisualStack.<component>
5+
export * from './components/Button';
6+
export * from './components/Spinner';
7+
8+
// modules that need scoping. i.e. the components they
9+
// export need to be scoped to VisualStack.<module>.<component>
10+
import * as BlankSlate from './components/BlankSlate';
11+
import * as Form from './components/Form';
12+
import * as List from './components/List';
13+
import * as MenuBar from './components/MenuBar';
14+
import * as Modal from './components/Modal';
15+
import * as PageHeader from './components/PageHeader';
16+
import * as Panel from './components/Panel';
17+
import * as Sidebar from './components/Sidebar';
18+
19+
export {
20+
BlankSlate,
21+
Form,
22+
List,
23+
MenuBar,
24+
Modal,
25+
PageHeader,
26+
Panel,
27+
Sidebar,
28+
};
29+

webpack.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var path = require('path');
2+
var webpack = require('webpack');
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
var env = process.env.NODE_ENV;
5+
var cssFileName = env === 'production' ? 'visual-stack.min.css' : 'visual-stack.css';
6+
7+
var config = {
8+
module: {
9+
loaders: [
10+
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
11+
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
12+
{ test: /\.png$|\.svg$/, loaders: ['url-loader'] },
13+
{ test: /\.eot$|\.ttf$|\.woff(2)?/, loaders: ['url-loader'] }
14+
]
15+
},
16+
output: {
17+
library: 'VisualStack',
18+
libraryTarget: 'umd'
19+
},
20+
externals: {
21+
'react': 'React',
22+
'react-dom': 'ReactDOM'
23+
},
24+
25+
// quiet the log output from the ExtractTextPlugin
26+
stats: { children: false },
27+
28+
plugins: [
29+
new ExtractTextPlugin(cssFileName),
30+
new webpack.optimize.OccurenceOrderPlugin(),
31+
new webpack.DefinePlugin({
32+
'process.env.NODE_ENV': JSON.stringify(env)
33+
})
34+
]
35+
};
36+
37+
if (env === 'production') {
38+
config.plugins.push(
39+
new webpack.optimize.UglifyJsPlugin({
40+
compressor: {
41+
warnings: false
42+
},
43+
output: {
44+
comments: false
45+
},
46+
sourceMap: false,
47+
})
48+
);
49+
}
50+
51+
module.exports = config;
52+

0 commit comments

Comments
 (0)