Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle for CDN #5796

Merged
merged 4 commits into from
Dec 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test/regressions/screenshots/output

# Exclude compiled files
/lib
/dist
icon-builder/js
icon-builder/jsx

Expand All @@ -23,3 +24,4 @@ jsconfig.json

# tmp
tmp*
*~
Copy link
Member

Choose a reason for hiding this comment

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

What is it for? Shouldn't it be in your user gitignore?

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ font in mind. So be sure to include it in your project. Here are
[some instructions](http://www.google.com/fonts#UsePlace:use/Collection:Roboto:400,300,500)
on how to do so.

### Packaging for use with separate React

For using with React and React DOM from a CDN or as separate minified scripts, you can build
files with UMD module support as follows:

npm install
Copy link
Member

Choose a reason for hiding this comment

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

I would rather be more explicit with:

```sh
npm install
```

npm run build:umd
npm run build:min

This will build two archives into the /dist folder

To see what's going on under the hood, you can use webpack directly:

webpack --display-reasons --display-modules --progress --optimize-minimize --colors --entry ./src/index.js
Copy link
Member

Choose a reason for hiding this comment

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

Same as before for explicitness



## Usage

Beginning with v0.15.0, Material-UI components require a theme to be provided. The quickest way to get up and running is by using the `MuiThemeProvider` to inject the theme into your application context. Following that, you can to use any of the components as demonstrated in the documentation.
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
},
"homepage": "http://material-ui.com/",
"scripts": {
"build": "npm run build:babel && npm run build:copy-files",
"build": "npm run build:babel && npm run build:copy-files && npm run build:umd && npm run build:min",
"build:icon-index": "babel-node ./scripts/icon-index-generator.js",
"build:babel": "babel ./src --ignore *.spec.js --out-dir ./build",
"build:copy-files": "babel-node ./scripts/copy-files.js",
"build:umd": "cross-env NODE_ENV=development webpack src/index.js --output-filename material-ui.js",
"build:min": "cross-env NODE_ENV=production webpack -p src/index.js --output-filename material-ui.min.js",
"build:docs": "babel-node ./scripts/build-api-docs.js",
"clean": "npm run clean:build",
"clean:docs": "rimraf docs/api/*",
Expand Down
61 changes: 61 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* eslint-disable flowtype/require-valid-file-annotation */
// webpack.config.js

const path = require('path');

const libraryName = 'material-ui';
const outputFile = `${libraryName}.js`;

const INDEX = path.join(__dirname, 'src/index.js');
const DIST = path.join(__dirname, 'dist');

const config = {
entry: {
'material-ui': INDEX,
},
devtool: 'source-map',
output: {
path: DIST,
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
},
externals: [
'react-addons-create-fragment',
'react-addons-transition-group',
{
react: {
root: 'React',
commonjs2: './react',
commonjs: ['./react'],
amd: 'react',
},
},
{
'react-dom': {
root: 'ReactDOM',
commonjs2: './react-dom',
commonjs: ['./react-dom'],
amd: 'react-dom',
},
},
],

Copy link
Member

Choose a reason for hiding this comment

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

Could you remove those blank lines?

module: {
loaders: [
{
test: /(\.jsx|\.js)$/,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need jsx: /\.js$/,

loader: 'babel',
exclude: /(node_modules)/,
},
],
},
resolve: {
root: path.resolve('./src'),
extensions: ['', '.js'],
},
};

module.exports = config;