Skip to content

Commit 25cf58a

Browse files
author
Ilê Caian
authored
Merge pull request #1 from codevor/build/webpack-structure
Build: Webpack Structure
2 parents c586ed6 + 0f928a5 commit 25cf58a

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

.npmignore

-6
This file was deleted.

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "@codevor/js-is-empty",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "📭Basic empty checker",
55
"main": "dist/js-is-empty.js",
66
"unpkg": "dist/js-is-empty.min.js",
7+
"files": [
8+
"dist"
9+
],
710
"scripts": {
811
"clean": "rimraf dist",
912
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
@@ -12,7 +15,7 @@
1215
"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

+22-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
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',
22-
umdNamedDefine: true,
2337
globalObject: "typeof self !== 'undefined' ? self : this"
2438
},
2539
module: {
@@ -38,12 +52,13 @@ module.exports = {
3852
},
3953
optimization: {
4054
minimize: true,
41-
minimizer: [new UglifyJsPlugin({ include: /\.min\.js$/ })]
55+
minimizer: [new TerserPlugin()]
4256
},
4357
plugins: [
4458
new webpack.DefinePlugin({
4559
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
46-
})
60+
}),
61+
new webpack.BannerPlugin(banner)
4762
],
4863
resolve: {
4964
extensions: ['.json', '.js']

0 commit comments

Comments
 (0)