Skip to content

Instantly share code, notes, and snippets.

@pjho
Last active May 16, 2017 08:42
Show Gist options
  • Save pjho/8de6b390077e0368d3f4f6e6f9220c5a to your computer and use it in GitHub Desktop.
Save pjho/8de6b390077e0368d3f4f6e6f9220c5a to your computer and use it in GitHub Desktop.
Basic Webpack 2 ES6 Build Config
// .babelrc
{
"presets": ["es2015"]
}
{
"name": "MY-LIBRARY",
"version": "0.1.0",
"description": "MY LIBRARY DESCRIPTION",
"main": "dist/index.js",
"module": "src/index.js",
"scripts": {
"test": "./node_modules/.bin/mocha",
"build": "webpack --config webpack.config.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/me/my.library.git"
},
"author": "ME",
"license": "MIT",
"bugs": {
"url": "https://github.com/me/my.library/issues"
},
"homepage": "https://github.com/me/my.library/#readme",
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.22.0",
"babel-register": "^6.23.0",
"chai": "^3.5.0",
"mocha": "^3.3.0",
"webpack": "^2.4.1"
}
}
const webpack = require("webpack");
module.exports = {
entry: {
"./dist/index": "./src/index.js",
},
output: {
path: `${ __dirname }`,
filename: "[name].js",
library: "MY_LIBRARY_NAME",
libraryTarget: "umd"
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: `babel-loader`,
query: {
presets: [`es2015`]
}
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({ minimize: true })
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment