Created
November 12, 2017 08:13
-
-
Save aliustaoglu/9a6ed6005796dc9b602308e22e1de4e8 to your computer and use it in GitHub Desktop.
Create NPM module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": ["env"], | |
"plugins": [ | |
"transform-object-rest-spread", | |
"transform-react-jsx" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class MyReactModule extends Component { | |
componentDidMount() { | |
} | |
render() { | |
return ( | |
<div> | |
MY REACT COMPONENT | |
</div> | |
); | |
} | |
} | |
MyReactModule.defaultProps = { | |
} | |
MyReactModule.PropTypes = { | |
} | |
export default MyReactModule; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my-npm-module", | |
"version": "0.0.1", | |
"description": "Simple React component", | |
"main": "build/index.js", | |
"dependencies": { | |
}, | |
"devDependencies": { | |
"prop-types": "^15.6.0", | |
"react": "^15.5.4", | |
"webpack": "^2.6.1", | |
"babel-cli": "^6.24.1", | |
"babel-core": "^6.24.1", | |
"babel-loader": "^7.0.0", | |
"babel-plugin-transform-object-rest-spread": "^6.23.0", | |
"babel-plugin-transform-react-jsx": "^6.24.1", | |
"babel-preset-env": "^1.5.1" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "webpack --watch", | |
"build": "webpack" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git+https://github.com/aliustaoglu/create-npm-module.git" | |
}, | |
"keywords": [ | |
"react" | |
], | |
"author": "Cuneyt Aliustaoglu", | |
"license": "ISC", | |
"bugs": { | |
"url": "https://github.com/aliustaoglu/create-npm-module/issues" | |
}, | |
"homepage": "https://github.com/aliustaoglu/create-npm-module#readme" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, 'build'), | |
filename: 'index.js', | |
libraryTarget: 'commonjs2' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
include: path.resolve(__dirname, 'src'), | |
exclude: /(node_modules|bower_components|build)/, | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['env'] | |
} | |
} | |
} | |
] | |
}, | |
externals: { | |
'react': 'commonjs react' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment