Skip to content

Commit

Permalink
Merge pull request #3 from codevor/build/webpack-structure
Browse files Browse the repository at this point in the history
Build: Webpack Structure
  • Loading branch information
Ilê Caian authored Dec 12, 2019
2 parents e1eec07 + 7ce4609 commit b615fdc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"name": "@codevor/js-is-type",
"version": "0.1.1",
"version": "0.2.0",
"description": "🎯Type-checking for 'Primitive' JS Types made easy!",
"main": "dist/js-is-type.js",
"unpkg": "dist/js-is-type.min.js",
"files": [
"dist"
],
"scripts": {
"clean": "rimraf dist",
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
"build:umd": "NODE_ENV=production webpack",
"lint": "eslint src tests",
"test": "jest --coverage",
"test": "jest --coverage --expand",
"test:watch": "jest --watch",
"coveralls": "cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"prepublish": "yarn lint && yarn test && yarn clean && yarn build:umd",
"prepublish": "yarn clean && yarn build:umd",
"commit": "git-cz"
},
"keywords": [
Expand Down Expand Up @@ -45,7 +48,7 @@
"husky": "^3.0.9",
"jest": "^24.9.0",
"rimraf": "^3.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"terser-webpack-plugin": "^2.2.3",
"webpack": "^4.41.1",
"webpack-cli": "^3.3.9"
},
Expand Down
32 changes: 24 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
const path = require('path');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');

const {
name,
version,
repository,
author,
license
} = require('./package.json');

const isProduction = process.env.NODE_ENV === 'production';
const mode = isProduction ? 'production' : 'development';

const libraryName = 'js-is-type';

const banner = `
${name} v${version}
${repository.url}
Copyright (c) ${author.replace(/ *\<[^)]*\> */g, ' ')}
This source code is licensed under the ${license} license found in the
LICENSE file in the root directory of this source tree.
`;

module.exports = {
mode,
mode: isProduction ? 'production' : 'development',
entry: {
[libraryName]: path.resolve(__dirname, 'src/index.js'),
[`${libraryName}.min`]: path.resolve(__dirname, 'src/index.js')
},
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
Expand All @@ -26,24 +41,25 @@ module.exports = {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
exclude: /node_modules/
}
}
]
},
optimization: {
minimize: true,
minimizer: [new UglifyJsPlugin({ include: /\.min\.js$/ })]
minimizer: [new TerserPlugin()]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
}),
new webpack.BannerPlugin(banner)
],
resolve: {
extensions: ['.json', '.js']
Expand Down

0 comments on commit b615fdc

Please sign in to comment.