Skip to content

Commit

Permalink
Add lib config
Browse files Browse the repository at this point in the history
  • Loading branch information
Raathi Kugarajan committed Nov 5, 2018
1 parent 999895f commit 0faaa2f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dist

# production
/build
/lib

# misc
.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions config/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = env => ({
hot: true,
port: 9000
},
optimization: {
minimizer: [new UglifyJsPlugin()]
},
devtool: "source-map",
module: {
rules: [
Expand Down
30 changes: 30 additions & 0 deletions config/webpack.lib.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const webpack = require("webpack");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const path = require("path");

module.exports = env => ({
entry: "./src/lib/index.js",
mode: "production",
output: {
path: path.resolve(__dirname, "../lib"),
filename: "lib.js",
library: "storyhooks",
libraryTarget: "umd"
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"]
},
optimization: {
minimizer: [new UglifyJsPlugin()]
},
devtool: "source-map",
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /(node_modules)/,
loader: "babel-loader"
}
]
}
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
},
"scripts": {
"start": "webpack-dev-server --env.development --config ./config/webpack.dev.config.js",
"build-sample": "react-scripts build",
"build-docs": "cross-env BABEL_ENV='production' rimraf dist && webpack --env.production --config ./config/webpack.dev.config.js",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build": "npm run clean && rollup -c",
"build": "cross-env BABEL_ENV='production' rimraf lib && webpack --env.production --config ./config/webpack.lib.config.js",
"clean": "rimraf ./dist"
},
"eslintConfig": {},
Expand All @@ -40,6 +40,7 @@
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^5.2.0",
"html-webpack-plugin": "^3.2.0",
"html-webpack-template": "^6.2.0",
"react": "^16.7.0-alpha.0",
Expand Down
39 changes: 0 additions & 39 deletions rollup.config.js

This file was deleted.

9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
safe-buffer "^5.0.1"
sha.js "^2.4.8"

cross-env@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
dependencies:
cross-spawn "^6.0.5"
is-windows "^1.0.0"

cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
Expand Down Expand Up @@ -3236,7 +3243,7 @@ is-symbol@^1.0.2:
dependencies:
has-symbols "^1.0.0"

is-windows@^1.0.2:
is-windows@^1.0.0, is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"

Expand Down

0 comments on commit 0faaa2f

Please sign in to comment.