Skip to content

Commit 26c336c

Browse files
authored
Merge pull request #4 from codevor/feature/build
Feature/build
2 parents b24b5a0 + ee9f127 commit 26c336c

File tree

12 files changed

+97
-4
lines changed

12 files changed

+97
-4
lines changed

.babelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
]
11+
]
12+
}

.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

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["airbnb-base", "prettier"]
3+
}

.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

.huskyrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "yarn lint",
4+
"pre-push": "yarn lint && yarn test"
5+
}
6+
}

.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

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tabWidth": 2,
3+
"singleQuote": true,
4+
"semi": true
5+
}

__tests__/.gitkeep

Whitespace-only changes.

package.json

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +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-
"test": "echo \"Error: no test specified\" && exit 1"
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"
813
},
914
"repository": {
1015
"type": "git",
@@ -16,5 +21,22 @@
1621
"bugs": {
1722
"url": "https://github.com/codevor/js-http-status/issues"
1823
},
19-
"homepage": "https://github.com/codevor/js-http-status#readme"
24+
"homepage": "https://github.com/codevor/js-http-status#readme",
25+
"devDependencies": {
26+
"@babel/cli": "^7.6.4",
27+
"@babel/core": "^7.6.4",
28+
"@babel/preset-env": "^7.6.3",
29+
"babel-jest": "^24.9.0",
30+
"babel-loader": "^8.0.6",
31+
"eslint": "^6.5.1",
32+
"eslint-config-airbnb-base": "^14.0.0",
33+
"eslint-config-prettier": "^6.4.0",
34+
"eslint-plugin-import": "^2.18.2",
35+
"husky": "^3.0.9",
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"
41+
}
2042
}

src/.gitkeep

Whitespace-only changes.

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)