-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Bundle for CDN #5796
Changes from all commits
671a013
24f48ef
dea6da0
88f62ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
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', | ||
}, | ||
}, | ||
], | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove those blank lines? |
||
module: { | ||
loaders: [ | ||
{ | ||
test: /(\.jsx|\.js)$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need |
||
loader: 'babel', | ||
exclude: /(node_modules)/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
root: path.resolve('./src'), | ||
extensions: ['', '.js'], | ||
}, | ||
}; | ||
|
||
module.exports = config; | ||
|
There was a problem hiding this comment.
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?