GithubHelp home page GithubHelp logo

chrisaliotta / template-reactnpm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from groftware/template-reactnpm

0.0 0.0 0.0 255 KB

Template to publishing a react component on npm

JavaScript 100.00%

template-reactnpm's Introduction

This project is created to simplify the process of publishing a React component to npm. For a full tutorial on publishing React component to npm, please refer to this guide

Guide

  1. Replace contents in /src with your React component.

  2. Edit webpack.config.js, replace the following:

    1. entry: './src/YOUR_COMPONENT.js' Replace value of entry to path to the entry point of your component.
    2. Replace output.filename to the name of your component
    	output: {
    		path: path.resolve('lib'),
    		filename: 'YOUR_COMPONENT.js',
    		libraryTarget: 'commonjs2',
    },
    
  3. Edit package.json, replace the following:

    1. "name": "YOUR_PACKAGE_NAME" Replace the value of name to your package name. This will be the name of the package that is published to npm and the name that is used when other people install your package using npm install YOUR_PACKAGE_NAME.
    2. Update the values of version and description to accordingly.
    3. "main": "./lib/YOUR_COMPONENT.js" replace YOUR_COMPONENT.js with the name that you've set in output.filename during Step #2
    4. If your component uses any other dependencies, make sure to add them into the peerDependencies list.
  4. Building your component by running npm build in your command line. This would generate the folder /lib which includes your component.

  5. Publishing to npm

    1. Make sure you've registered an npm account
    2. Run npm login in your command line, and enter your credentials.
    3. Run npm publish, and your React component will be uploaded to npm! You can find it at https://www.npmjs.com/package/[YOUR PACKAGE NAME] or your npm profile.
  6. To update your package, make sure you remember to increment the version in package.json, and then perform Step #5 again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.