Skip to content

Commit 50272ca

Browse files
committed
refactor: webpack.config.js to create license file
1 parent 8cf9b23 commit 50272ca

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "@codevor/logger.js",
3-
"version": "0.2.2",
3+
"version": "0.3.0",
44
"description": "💢 Make logging friendlier, simpler and use emojis in your messages. Try logger!",
55
"main": "dist/logger.js",
66
"unpkg": "dist/logger.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": [

webpack.config.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,50 @@ const path = require('path');
22
const webpack = require('webpack');
33
const TerserPlugin = require('terser-webpack-plugin');
44

5+
const {
6+
name,
7+
version,
8+
repository,
9+
author,
10+
license
11+
} = require('./package.json');
12+
513
const isProduction = process.env.NODE_ENV === 'production';
6-
const mode = isProduction ? 'production' : 'development';
714

815
const libraryName = 'logger';
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
},
16-
devtool: 'source-map',
1731
output: {
18-
path: path.join(__dirname, 'dist'),
32+
filename: '[name].js',
33+
path: path.resolve(__dirname, 'dist'),
1934
library: libraryName,
2035
libraryTarget: 'umd',
21-
filename: '[name].js',
2236
globalObject: "typeof self !== 'undefined' ? self : this"
2337
},
2438
module: {
2539
rules: [
2640
{
2741
test: /\.js$/,
42+
exclude: /node_modules/,
2843
use: {
2944
loader: 'babel-loader',
3045
options: {
3146
presets: ['@babel/preset-env']
3247
}
33-
},
34-
exclude: /node_modules/
48+
}
3549
}
3650
]
3751
},
@@ -42,7 +56,8 @@ module.exports = {
4256
plugins: [
4357
new webpack.DefinePlugin({
4458
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
45-
})
59+
}),
60+
new webpack.BannerPlugin(banner)
4661
],
4762
resolve: {
4863
extensions: ['.json', '.js']

0 commit comments

Comments
 (0)