Skip to content

Commit ee9f127

Browse files
committed
Configured webpack generate bundle
1 parent ed42050 commit ee9f127

File tree

6 files changed

+60
-5
lines changed

6 files changed

+60
-5
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lib
2+
**/node_modules
3+
**/webpack.config.js

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
node_modules
2-
coverage
2+
*.log
33
.DS_Store
4+
dist
5+
lib
6+
coverage
47
yarn.lock
58
package-lock.json

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
*.log
3+
src
4+
__tests__
5+
coverage

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
"name": "js-http-status",
33
"version": "0.1.0",
44
"description": "[![License][license-badge]][license-url]",
5-
"main": "index.js",
5+
"main": "lib/index.js",
66
"scripts": {
7-
"lint": "yarn eslint src/**/*.js",
8-
"test": "jest"
7+
"clean": "rimraf lib dist",
8+
"build": "babel src --out-dir lib",
9+
"build:umd": "NODE_ENV=production webpack src/index.js",
10+
"lint": "eslint src",
11+
"test": "jest",
12+
"prepublish": "yarn lint && yarn test && yarn clean && yarn build && yarn build:umd"
913
},
1014
"repository": {
1115
"type": "git",
@@ -19,14 +23,20 @@
1923
},
2024
"homepage": "https://github.com/codevor/js-http-status#readme",
2125
"devDependencies": {
26+
"@babel/cli": "^7.6.4",
2227
"@babel/core": "^7.6.4",
2328
"@babel/preset-env": "^7.6.3",
2429
"babel-jest": "^24.9.0",
30+
"babel-loader": "^8.0.6",
2531
"eslint": "^6.5.1",
2632
"eslint-config-airbnb-base": "^14.0.0",
2733
"eslint-config-prettier": "^6.4.0",
2834
"eslint-plugin-import": "^2.18.2",
2935
"husky": "^3.0.9",
30-
"jest": "^24.9.0"
36+
"jest": "^24.9.0",
37+
"rimraf": "^3.0.0",
38+
"uglifyjs-webpack-plugin": "^2.2.0",
39+
"webpack": "^4.41.1",
40+
"webpack-cli": "^3.3.9"
3141
}
3242
}

src/index.js

Whitespace-only changes.

webpack.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require('path');
2+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
3+
4+
const isProduction = process.env.NODE_ENV === 'production';
5+
const mode = isProduction ? 'production' : 'development';
6+
7+
module.exports = {
8+
mode,
9+
entry: {
10+
main: path.resolve(__dirname, 'src/index.js'),
11+
},
12+
output: {
13+
path: path.resolve(__dirname, 'dist'),
14+
filename: isProduction ? 'http-status.min.js' : 'http-status.js',
15+
library: 'HttpStatus',
16+
libraryTarget: 'umd',
17+
},
18+
module: {
19+
rules: [
20+
{
21+
test: /\.js$/,
22+
loader: 'babel-loader',
23+
exclude: /node_modules/,
24+
}
25+
]
26+
},
27+
optimization: {
28+
minimize: isProduction,
29+
minimizer: [new UglifyJsPlugin()]
30+
},
31+
resolve: {
32+
extensions: [".js"]
33+
}
34+
};

0 commit comments

Comments
 (0)