Skip to content

Commit

Permalink
refactor: Renovate project base files
Browse files Browse the repository at this point in the history
  • Loading branch information
melck committed Aug 4, 2019
1 parent 1952d54 commit 88a56a4
Show file tree
Hide file tree
Showing 10 changed files with 3,258 additions and 102 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# The JSON files contain newlines inconsistently
[*.json]
insert_final_newline = ignore

# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended",
],
"rules": {
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-var-requires": "off"
}
}
61 changes: 44 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# System Files
.DS_Store
Thumbs.db

# IDE - VSCode
.vscode/

# Coverage directory used by tools like istanbul
coverage

# IDEs and editors
.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
# Dependency directories
node_modules/
jspm_packages/

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Optional npm cache directory
.npm

# Coverage directory used by tools like istanbul
coverage
# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Yarn Integrity file
.yarn-integrity

# node-waf configuration
.lock-wscript
# dotenv environment variables file
.env

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# next.js build output
.next

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
dist/
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};
102 changes: 53 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,86 @@
# webpack-bundle-tracker

[![Join the chat at https://gitter.im/owais/webpack-bundle-tracker](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owais/webpack-bundle-tracker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# Webpack Bundle Tracker [![Join the chat at https://gitter.im/owais/webpack-bundle-tracker](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owais/webpack-bundle-tracker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Spits out some stats about webpack compilation process to a file.

<br>

#### Install
## Install

```bash
npm install --save-dev webpack-bundle-tracker
```

```bash
yarn add --dev webpack-bundle-tracker
```

<br>

#### Usage
## Usage

```javascript
var BundleTracker = require('webpack-bundle-tracker');
var BundleTracker = require("webpack-bundle-tracker");
module.exports = {
context: __dirname,
entry: {
app: ['./app']
},

output: {
path: require("path").resolve('./assets/bundles/'),
filename: "[name]-[hash].js",
publicPath: 'http://localhost:3000/assets/bundles/',
},

plugins: [
new BundleTracker({path: __dirname, filename: './assets/webpack-stats.json'})
]
}
context: __dirname,
entry: {
app: ["./app"]
},

output: {
path: require("path").resolve("./assets/bundles/"),
filename: "[name]-[hash].js",
publicPath: "http://localhost:3000/assets/bundles/"
},

plugins: [
new BundleTracker({
path: __dirname,
filename: "./assets/webpack-stats.json"
})
]
};
```

`./assets/webpack-stats.json` will look like,

```json
{
"status":"done",
"chunks":{
"app":[{
"name":"app-0828904584990b611fb8.js",
"publicPath":"http://localhost:3000/assets/bundles/app-0828904584990b611fb8.js",
"path":"/home/user/project-root/assets/bundles/app-0828904584990b611fb8.js"
}]
}
"status": "done",
"chunks": {
"app": [
{
"name": "app-0828904584990b611fb8.js",
"publicPath": "http://localhost:3000/assets/bundles/app-0828904584990b611fb8.js",
"path": "/home/user/project-root/assets/bundles/app-0828904584990b611fb8.js"
}
]
}
}
```

In case webpack is still compiling, it'll look like,


```json
{
"status":"compiling",
"status": "compiling"
}
```



And errors will look like,

```json
{
"status": "error",
"file": "/path/to/file/that/caused/the/error",
"error": "ErrorName",
"message": "ErrorMessage"
"status": "error",
"file": "/path/to/file/that/caused/the/error",
"error": "ErrorName",
"message": "ErrorMessage"
}
```

`ErrorMessage` shows the line and column that caused the error.



And in case `logTime` option is set to `true`, the output will look like,

```
{
"status":"done",
Expand All @@ -92,18 +96,18 @@ And in case `logTime` option is set to `true`, the output will look like,
}
```



By default, the output JSON will not be indented. To increase readability, you can use the `indent`
option to make the output legible. By default it is off. The value that is set here will be directly
passed to the `space` parameter in `JSON.stringify`. More information can be found here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
passed to the `space` parameter in `JSON.stringify`. More information can be found [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)


<br>

#### Bundle Tracker Options
## Options

* `filename` - Name of the bundle tracker JSON file.
* `logTime` - Optional boolean property to output `startTime` and `endTime` in bundle tracker file.
* `path` - Optional bundle tracker output path.
* `publicPath` - Optional property to override `output.publicPath`.
| Name | Type | Default | Description |
| ------------ | ----------- | ---------------------- | ------------------------------------------------------------------------ |
| `path` | `{String}` | `'.'` | Output directory of bundle tracker JSON file . |
| `filename` | `{String}` | `'webpack-stats.json'` | Name of the bundle tracker JSON file. |
| `publicPath` | `{String}` | `?` | Override `output.publicPath` from Webpack config. |
| `logTime` | `{Boolean}` | `false` | Output `startTime` and `endTime` properties in bundle tracker JSON file. |
33 changes: 33 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Compiler } from 'webpack';

export = Plugin;

declare class Plugin {
constructor(options?: Plugin.Options);

apply(compiler: Compiler): void;
}

declare namespace Plugin {
interface Options {
/**
* Output directory of the bundle tracker JSON file
* Default: `'.'`
*/
path: string;
/**
* Name of the bundle tracker JSON file.
* Default: `'webpack-stats.json'`
*/
filename: string;
/**
* Property to override default `output.publicPath` from Webpack config file.
*/
publicPath: string;
/**
* Output `startTime` and `endTime` properties to JSON file.
* Default: `false`
*/
logTime: boolean;
}
}
File renamed without changes.
48 changes: 28 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@
"name": "webpack-bundle-tracker",
"version": "0.4.2-beta",
"description": "Spits out some stats about webpack compilation process to a file",
"license": "MIT",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/owais/webpack-bundle-tracker.git"
},
"keywords": [
"webpack",
"bundle",
"files",
"plugin",
"stats",
"files"
"webpack"
],
"homepage": "https://github.com/owais/webpack-bundle-tracker",
"bugs": "https://github.com/owais/webpack-bundle-tracker/issues",
"repository": "https://github.com/owais/webpack-bundle-tracker.git",
"license": "MIT",
"author": "Owais Lone",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/brentertz/scapegoat/blob/master/LICENSE-MIT"
}
],
"bugs": {
"url": "https://github.com/owais/webpack-bundle-tracker/issues"
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"pretest": "prettier --check lib/*.js",
"posttest": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"deep-extend": "^0.6.0",
"mkdirp": "^0.5.1",
"strip-ansi": "^2.0.1"
"strip-ansi": "^5.2.0"
},
"devDependencies": {
"@types/deep-extend": "^0.4.31",
"@types/mkdirp": "^0.5.2",
"@types/node": "^12.6.9",
"@types/webpack": "^4.32.1",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"commitizen": "^4.0.3",
"cz-conventional-changelog": "^3.0.2",
"eslint": "^6.1.0",
"prettier": "^1.18.2",
"standard-version": "^7.0.0",
"typescript": "^3.5.3"
}
}
Loading

0 comments on commit 88a56a4

Please sign in to comment.