Skip to content

Commit 6ef1b9f

Browse files
authored
Merge pull request #40 from codevor/develop
Develop
2 parents 7971b92 + ddee896 commit 6ef1b9f

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

.npmignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
{
22
"name": "@codevor/js-http-status",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "🔍 A simple way to catch HTTP statuses with JavaScript.",
5-
"main": "dist/index",
5+
"main": "dist/js-http-status.js",
6+
"unpkg": "dist/js-http-status.min.js",
7+
"files": [
8+
"dist"
9+
],
610
"scripts": {
711
"commit": "git-cz",
812
"clean": "rimraf dist",
913
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
10-
"build": "NODE_ENV=production webpack",
14+
"build:umd": "NODE_ENV=production webpack",
1115
"lint": "eslint src tests",
1216
"test": "jest --coverage --expand",
1317
"test:watch": "jest --watch",
14-
"prepublish": "yarn lint && yarn test && yarn clean && yarn build",
1518
"coveralls": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
16-
"generate-docs": "jsdoc --configure .jsdocrc"
19+
"generate-docs": "jsdoc --configure .jsdocrc",
20+
"prepublish": "yarn clean && yarn build:umd"
1721
},
1822
"repository": {
1923
"type": "git",
@@ -50,7 +54,7 @@
5054
"jest": "^24.9.0",
5155
"jsdoc": "^3.6.3",
5256
"rimraf": "^3.0.0",
53-
"uglifyjs-webpack-plugin": "^2.2.0",
57+
"terser-webpack-plugin": "^2.2.3",
5458
"webpack": "^4.41.1",
5559
"webpack-cli": "^3.3.9"
5660
},

webpack.config.js

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,65 @@
11
const path = require('path');
2-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
2+
const webpack = require('webpack');
3+
const TerserPlugin = require('terser-webpack-plugin');
4+
5+
const {
6+
name,
7+
version,
8+
repository,
9+
author,
10+
license
11+
} = require('./package.json');
312

413
const isProduction = process.env.NODE_ENV === 'production';
5-
const mode = isProduction ? 'production' : 'development';
14+
15+
const libraryName = 'js-http-status';
16+
17+
const banner = `
18+
${name} v${version}
19+
${repository.url}
20+
Copyright (c) ${author.replace(/ *\<[^)]*\> */g, ' ')}
21+
This source code is licensed under the ${license} license found in the
22+
LICENSE file in the root directory of this source tree.
23+
`;
624

725
module.exports = {
8-
mode,
26+
mode: isProduction ? 'production' : 'development',
927
entry: {
10-
app: path.resolve(__dirname, 'src/index.js')
28+
[libraryName]: path.resolve(__dirname, 'src/index.js'),
29+
[`${libraryName}.min`]: path.resolve(__dirname, 'src/index.js')
1130
},
1231
output: {
32+
filename: '[name].js',
1333
path: path.resolve(__dirname, 'dist'),
14-
filename: 'index.js',
15-
library: 'js-http-status',
34+
library: libraryName,
1635
libraryTarget: 'umd',
17-
umdNamedDefine: true,
18-
globalObject: 'this'
36+
globalObject: "typeof self !== 'undefined' ? self : this"
1937
},
2038
module: {
2139
rules: [
2240
{
2341
test: /\.js$/,
42+
exclude: /node_modules/,
2443
use: {
2544
loader: 'babel-loader',
2645
options: {
2746
presets: ['@babel/preset-env']
2847
}
29-
},
30-
exclude: /node_modules/
48+
}
3149
}
3250
]
3351
},
3452
optimization: {
35-
minimize: isProduction,
36-
minimizer: [
37-
new UglifyJsPlugin({
38-
sourceMap: true,
39-
include: /\.min\.js$/
40-
})
41-
]
53+
minimize: true,
54+
minimizer: [new TerserPlugin()]
4255
},
56+
plugins: [
57+
new webpack.DefinePlugin({
58+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
59+
}),
60+
new webpack.BannerPlugin(banner)
61+
],
4362
resolve: {
44-
extensions: ['.js']
63+
extensions: ['.json', '.js']
4564
}
4665
};

0 commit comments

Comments
 (0)