Skip to content

Commit

Permalink
Use webpack to build the library
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinicius Dallacqua committed Mar 13, 2018
1 parent 4f2a83c commit 8fe9708
Show file tree
Hide file tree
Showing 4 changed files with 1,555 additions and 229 deletions.
40 changes: 40 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"react-error-guard": {
"configuration": {
"config": {
"webpackOptions": {
"module": {
"rules": [
{
"test": {},
"exclude": "/node_modules/",
"loader": "'babel-loader'",
"options": {
"presets": [
"'env'"
]
}
}
]
},
"plugins": [
"new UglifyJSPlugin()"
],
"entry": "\"./src/index\"",
"output": {
"filename": "'[name].bundle.js'",
"path": "path.resolve(__dirname, 'lib/')"
}
},
"topScope": [
"const webpack = require('webpack')",
"const path = require('path')",
"/*\n * We've enabled UglifyJSPlugin for you! This minifies your app\n * in order to load faster and run less javascript.\n *\n * https://github.com/webpack-contrib/uglifyjs-webpack-plugin\n *\n */",
"const UglifyJSPlugin = require('uglifyjs-webpack-plugin');",
"\n"
],
"configName": "config"
}
}
}
}
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"prettier": "node scripts/prettier",
"prettier:all": "node scripts/prettier write",
"build": "rm -rf lib/* && NODE_ENV=production BABEL_ENV=production babel src/ --copy-files --out-dir lib/ --ignore '.*(spec).js'",
"build": "rimraf lib/* && NODE_ENV=production BABEL_ENV=production node_modules/.bin/webpack --config webpack.config.js",
"prepublishOnly": "yarn prettier && yarn build"
},
"repository": "WebCloud/react-error-reporter",
Expand All @@ -27,18 +27,20 @@
"author": "Vinicius <dev.webx@gmail.com>",
"dependencies": {
"anser": "1.4.6",
"babel-preset-env": "^1.6.1",
"html-entities": "1.2.1",
"settle-promise": "1.0.0"
"settle-promise": "1.0.0",
"uglifyjs-webpack-plugin": "^1.2.3"
},
"devDependencies": {
"@babel/code-frame": "7.0.0-beta.38",
"@babel/core": "7.0.0-beta.38",
"@babel/runtime": "7.0.0-beta.38",
"babel-cli": "^6.26.0",
"babel-core": "^7.0.0-bridge.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.2",
"babel-jest": "^22.1.0",
"babel-loader": "^8.0.0-beta.0",
"babel-loader": "^7.1.4",
"babel-preset-react-app": "^3.1.1",
"chalk": "^2.3.2",
"chokidar": "^2.0.0",
Expand All @@ -61,6 +63,7 @@
"react-dom": "^16.0.0",
"rimraf": "^2.6.1",
"source-map": "0.5.6",
"webpack": "^3.6.0"
"webpack": "^4.1.1",
"webpack-cli": "^2.0.11"
}
}
55 changes: 55 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const webpack = require('webpack');
const path = require('path');

/*
* We've enabled UglifyJSPlugin for you! This minifies your app
* in order to load faster and run less javascript.
*
* https://github.com/webpack-contrib/uglifyjs-webpack-plugin
*
*/

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
entry: './src/index',

output: {
library: 'react-error-guard',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'lib/'),
},

module: {
rules: [
{
test: /\.js?$/,
exclude: /node_modules/,
loader: 'babel-loader',

options: {
presets: ['env'],
},
},
],
},

externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
umd: 'react',
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
umd: 'react-dom',
},
},

plugins: [new UglifyJSPlugin()],
};
Loading

0 comments on commit 8fe9708

Please sign in to comment.