Skip to content

Commit b615fdc

Browse files
author
Ilê Caian
authored
Merge pull request #3 from codevor/build/webpack-structure
Build: Webpack Structure
2 parents e1eec07 + 7ce4609 commit b615fdc

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

.npmignore

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

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
{
22
"name": "@codevor/js-is-type",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "🎯Type-checking for 'Primitive' JS Types made easy!",
55
"main": "dist/js-is-type.js",
66
"unpkg": "dist/js-is-type.min.js",
7+
"files": [
8+
"dist"
9+
],
710
"scripts": {
811
"clean": "rimraf dist",
912
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
1013
"build:umd": "NODE_ENV=production webpack",
1114
"lint": "eslint src tests",
12-
"test": "jest --coverage",
15+
"test": "jest --coverage --expand",
1316
"test:watch": "jest --watch",
1417
"coveralls": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
15-
"prepublish": "yarn lint && yarn test && yarn clean && yarn build:umd",
18+
"prepublish": "yarn clean && yarn build:umd",
1619
"commit": "git-cz"
1720
},
1821
"keywords": [
@@ -45,7 +48,7 @@
4548
"husky": "^3.0.9",
4649
"jest": "^24.9.0",
4750
"rimraf": "^3.0.0",
48-
"uglifyjs-webpack-plugin": "^2.2.0",
51+
"terser-webpack-plugin": "^2.2.3",
4952
"webpack": "^4.41.1",
5053
"webpack-cli": "^3.3.9"
5154
},

webpack.config.js

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

513
const isProduction = process.env.NODE_ENV === 'production';
6-
const mode = isProduction ? 'production' : 'development';
714

815
const libraryName = 'js-is-type';
916

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+
`;
24+
1025
module.exports = {
11-
mode,
26+
mode: isProduction ? 'production' : 'development',
1227
entry: {
1328
[libraryName]: path.resolve(__dirname, 'src/index.js'),
1429
[`${libraryName}.min`]: path.resolve(__dirname, 'src/index.js')
1530
},
1631
devtool: 'source-map',
1732
output: {
18-
path: path.resolve(__dirname, 'dist'),
1933
filename: '[name].js',
34+
path: path.resolve(__dirname, 'dist'),
2035
library: libraryName,
2136
libraryTarget: 'umd',
2237
umdNamedDefine: true,
@@ -26,24 +41,25 @@ module.exports = {
2641
rules: [
2742
{
2843
test: /\.js$/,
44+
exclude: /node_modules/,
2945
use: {
3046
loader: 'babel-loader',
3147
options: {
3248
presets: ['@babel/preset-env']
3349
}
34-
},
35-
exclude: /node_modules/
50+
}
3651
}
3752
]
3853
},
3954
optimization: {
4055
minimize: true,
41-
minimizer: [new UglifyJsPlugin({ include: /\.min\.js$/ })]
56+
minimizer: [new TerserPlugin()]
4257
},
4358
plugins: [
4459
new webpack.DefinePlugin({
4560
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
46-
})
61+
}),
62+
new webpack.BannerPlugin(banner)
4763
],
4864
resolve: {
4965
extensions: ['.json', '.js']

0 commit comments

Comments
 (0)