Skip to content

Commit 5fb62bb

Browse files
chore: init
0 parents  commit 5fb62bb

File tree

17 files changed

+10787
-0
lines changed

17 files changed

+10787
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_size = 2
6+
indent_style = space
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
parser: 'babel-eslint',
5+
sourceType: 'module'
6+
},
7+
extends: [
8+
'@nuxtjs'
9+
]
10+
}

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
*.iml
3+
.idea
4+
*.log*
5+
.nuxt*
6+
.vscode
7+
.DS_STORE
8+
coverage
9+
dist

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: node_js
2+
node_js:
3+
- "8"
4+
- "9"
5+
- "10"
6+
- "11"
7+
cache:
8+
yarn: true
9+
directories:
10+
- node_modules
11+
install:
12+
- yarn
13+
script:
14+
- yarn test
15+
after_success:
16+
- yarn coverage

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Alexander Lichter <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Nuxt Bundle Buddy - Don't fight your webpack bundle, become friends!
2+
[![npm (scoped with tag)](https://img.shields.io/npm/v/nuxt-bundle-buddy/latest.svg?style=flat-square)](https://npmjs.com/package/nuxt-bundle-buddy)
3+
[![npm](https://img.shields.io/npm/dt/nuxt-bundle-buddy.svg?style=flat-square)](https://npmjs.com/package/nuxt-bundle-buddy)
4+
[![Build Status](https://travis-ci.com/Developmint/nuxt-bundle-buddy.svg?branch=master)](https://travis-ci.com/Developmint/nuxt-bundle-buddy)
5+
[![codecov](https://codecov.io/gh/Developmint/nuxt-bundle-buddy/branch/master/graph/badge.svg)](https://codecov.io/gh/Developmint/nuxt-bundle-buddy)
6+
[![Dependencies](https://david-dm.org/Developmint/nuxt-bundle-buddy/status.svg?style=flat-square)](https://david-dm.org/Developmint/nuxt-bundle-buddy)
7+
[![js-standard-style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com)
8+
[![thanks](https://img.shields.io/badge/thanks-%E2%99%A5-ff69b4.svg)](https://thanks.lichter.io/)
9+
10+
>
11+
12+
[📖 **Release Notes**](./CHANGELOG.md)
13+
14+
## Features
15+
16+
* Analyzes your bundle and visualize improvement opportunities
17+
* Built on top of [bundle-buddy](https://github.com/samccone/bundle-buddy)
18+
* Fully tested!
19+
* Nuxt 2 support
20+
21+
## Setup
22+
23+
- Install [`bundle-buddy`](https://github.com/samccone/bundle-buddy) globally,
24+
**otherwise you won't see anything**
25+
- Add the `nuxt-bundle-buddy` dependency using yarn or npm to your project
26+
- Add `nuxt-bundle-buddy` to `modules` section of `nuxt.config.js`:
27+
28+
```js
29+
{
30+
modules: [
31+
'nuxt-bundle-buddy',
32+
],
33+
34+
bundleBuddy: {
35+
// your settings here
36+
// Usually you don't need any though, so you can fully omit the
37+
// bundleBuddy object
38+
}
39+
}
40+
```
41+
42+
- Run a Nuxt analyze build (`yarn build --analyze` or `npm run build -- --analyze`)
43+
44+
## Options
45+
46+
47+
```js
48+
// file: nuxt.config.js
49+
export default {
50+
bundleBuddy: {
51+
removeDefaultAnalyzer: true // disable to keep default webpack analyzer
52+
}
53+
}
54+
```
55+
56+
## Development
57+
58+
- Clone this repository
59+
- Install dependencies using `yarn install` or `npm install`
60+
- Start development server using `npm run dev`
61+
62+
## License
63+
64+
[MIT License](./LICENSE)
65+
66+
Copyright (c) Alexander Lichter

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

lib/module.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import consola from 'consola'
2+
import BundleBuddyWebpackPlugin from 'bundle-buddy-webpack-plugin'
3+
4+
const logger = consola.withTag('nuxt-bundle-buddy')
5+
6+
export default function nuxtBundleBuddy() {
7+
const { build: { analyze }, dev, bundleBuddy } = this.options
8+
9+
const options = Object.assign({}, { removeDefaultAnalyzer: true }, bundleBuddy)
10+
11+
if (!dev && analyze) {
12+
logger.info('Loading module')
13+
this.extendBuild(webpackFn(options))
14+
}
15+
}
16+
17+
const webpackFn = options => (config, { isServer }) => {
18+
// Only evaluate client bundle
19+
if (isServer) {
20+
return
21+
}
22+
23+
// Remove normal analyze plugin if option is set
24+
if (options.removeDefaultAnalyzer) {
25+
const pluginIndex = config.plugins.findIndex(p => p.constructor.toString().includes('BundleAnalyzer'))
26+
config.plugins.splice(pluginIndex, 1)
27+
}
28+
29+
// Add bundle-buddy-plugin and **force sourcemaps**
30+
31+
config.devtool = 'source-map'
32+
config.plugins.push(new BundleBuddyWebpackPlugin({ sam: true }))
33+
}
34+
35+
module.exports.meta = require('../package.json')

package.json

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"name": "nuxt-bundle-buddy",
3+
"version": "0.0.1",
4+
"description": "Don't fight your webpack bundle, become friends!",
5+
"license": "MIT",
6+
"contributors": [
7+
{
8+
"name": "Alexander Lichter <[email protected]>"
9+
}
10+
],
11+
"main": "lib/module.js",
12+
"repository": {
13+
"mode": "git",
14+
"url": "git+https://github.com/Developmint/nuxt-bundle-buddy"
15+
},
16+
"bugs": {
17+
"url": "https://github.com/Developmint/nuxt-bundle-buddy/issues"
18+
},
19+
"publishConfig": {
20+
"access": "public"
21+
},
22+
"scripts": {
23+
"dev": "nuxt build --config-file test/fixture/configs/default.js",
24+
"lint": "eslint lib test",
25+
"test": "yarn run lint && jest --detectOpenHandles",
26+
"release": "standard-version && git push --follow-tags && npm publish",
27+
"commitlint": "commitlint -E HUSKY_GIT_PARAMS",
28+
"coverage": "codecov",
29+
"webpack-defaults": "webpack-defaults",
30+
"defaults": "webpack-defaults"
31+
},
32+
"eslintIgnore": [
33+
"lib/templates/*.*"
34+
],
35+
"files": [
36+
"lib"
37+
],
38+
"keywords": [
39+
"nuxtjs",
40+
"nuxt",
41+
"nuxt-module",
42+
"bundle-buddy",
43+
"webpack",
44+
"visualize"
45+
],
46+
"engines": {
47+
"node": ">=8.0.0",
48+
"npm": ">=5.0.0"
49+
},
50+
"jest": {
51+
"testEnvironment": "node",
52+
"collectCoverage": true,
53+
"coveragePathIgnorePatterns": [
54+
"/node_modules/",
55+
"/test/fixture"
56+
],
57+
"forceExit": true
58+
},
59+
"dependencies": {
60+
"bundle-buddy-webpack-plugin": "^0.3.0",
61+
"consola": "2.0.2"
62+
},
63+
"devDependencies": {
64+
"@commitlint/cli": "^7.2.1",
65+
"@commitlint/config-conventional": "^7.1.2",
66+
"@nuxtjs/eslint-config": "^0.0.1",
67+
"babel-eslint": "^10.0.1",
68+
"codecov": "^3.1.0",
69+
"eslint": "^5.8.0",
70+
"eslint-config-standard": "^12.0.0",
71+
"eslint-plugin-import": "^2.14.0",
72+
"eslint-plugin-jest": "^21.26.2",
73+
"eslint-plugin-node": "^8.0.0",
74+
"eslint-plugin-promise": "^4.0.1",
75+
"eslint-plugin-standard": "^4.0.0",
76+
"eslint-plugin-vue": "^5.0.0-beta.3",
77+
"husky": "^1.1.3",
78+
"jest": "^23.6.0",
79+
"jsdom": "^13.0.0",
80+
"nuxt-edge": "^2.3.0-25686119.17e0890",
81+
"standard-version": "^4.4.0",
82+
"webpack-defaults": "^2.3.0"
83+
},
84+
"resolutions": {
85+
"bundle-buddy-webpack-plugin/bundle-buddy": "0.2.1"
86+
},
87+
"husky": {
88+
"hooks": {
89+
"pre-commit": "yarn run lint",
90+
"commit-msg": "yarn run commitlint"
91+
}
92+
}
93+
}

renovate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"@nuxtjs"
4+
]
5+
}

0 commit comments

Comments
 (0)