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

[WIP] [Core] Setup umd build #4342

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
npm-debug.log
build
dist
coverage

# Exclude compiled files
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:icon-index && npm run build:babel && npm run build:copy-files",
"build": "npm run build:icon-index && 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.umd.js dist/MaterialUI.js",
"build:min": "cross-env NODE_ENV=production webpack -p src/index.umd.js dist/MaterialUI.min.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

These two targets gave errors for me. I changed them to:

"build:umd": "cross-env NODE_ENV=development webpack src/index.umd.js --output-filename dist/MaterialUI.js",
"build:min": "cross-env NODE_ENV=production webpack -p src/index.umd.js --output-filename dist/MaterialUI.min.js",

and the build ran correctly.

"clean:build": "rimraf build",
"lint": "eslint src docs/src test/integration && echo \"eslint: no lint errors\"",
"lint:find-rules": "eslint-find-rules -u .eslintrc.js",
Expand Down
5 changes: 5 additions & 0 deletions src/index.umd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

export * from './index';
export * from './styles';
59 changes: 59 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
var webpack = require('webpack')

module.exports = {

output: {
library: 'MaterialUI',
libraryTarget: 'umd'
},

externals: [
{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
},
'react-addons-transition-group': {
root: ['React', 'addons', 'TransitionGroup'],
commonjs2: 'react-addons-transition-group',
commonjs: 'react-addons-transition-group',
amd: 'react-addons-transition-group',
},
'react-addons-create-fragment': {
root: ['React', 'addons', 'createFragment'],
commonjs2: 'react-addons-create-fragment',
commonjs: 'react-addons-create-fragment',
amd: 'react-addons-create-fragment',
}
}
],

module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
}
]
},

node: {
Buffer: false
},

plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
}