Skip to content

Instantly share code, notes, and snippets.

@BrianJenney
Created November 13, 2021 14:14
Show Gist options
  • Save BrianJenney/592db8a44fad46eacea39d78446493d2 to your computer and use it in GitHub Desktop.
Save BrianJenney/592db8a44fad46eacea39d78446493d2 to your computer and use it in GitHub Desktop.
npm library starter
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": false
}
]
],
"plugins": ["@babel/plugin-transform-runtime"]
}
export const myRadFunction = (...args) => {
return [...args]
}
{
"name": "name-npm-lib-starter",
"version": "1.3.0",
"description": "",
"main": "lib/index.js",
"files": [
"/lib"
],
"scripts": {
"preversion": "npm run build",
"version": "npm run build",
"build": "NODE_ENV=production npx webpack",
"start": "NODE_ENV=development npx webpack --progress --color --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"webpack": "^5.63.0"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.16.0",
"babel-loader": "^8.2.3",
"webpack-cli": "^4.9.1"
}
}
const path = require('path');
module.exports = {
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
entry: './index.js',
output: {
path: path.join(__dirname, 'lib'),
chunkFilename: '[name].[chunkhash].js',
filename: '[name].js',
libraryTarget: 'umd'
},
context: __dirname,
devtool: process.env.NODE_ENV === 'production' ? undefined : 'source-map',
mode: process.env.NODE_ENV
};
@BrianJenney
Copy link
Author

Instructions on exposing an NPM package: https://www.loom.com/share/25ec04ee095f45179ac9b3e5e4224a0d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment