Created
November 13, 2021 14:14
-
-
Save BrianJenney/592db8a44fad46eacea39d78446493d2 to your computer and use it in GitHub Desktop.
npm library starter
This file contains 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
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"useBuiltIns": false | |
} | |
] | |
], | |
"plugins": ["@babel/plugin-transform-runtime"] | |
} | |
This file contains 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
export const myRadFunction = (...args) => { | |
return [...args] | |
} |
This file contains 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": "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" | |
} | |
} |
This file contains 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
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 | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions on exposing an NPM package: https://www.loom.com/share/25ec04ee095f45179ac9b3e5e4224a0d