Skip to content

Commit 1ce9812

Browse files
feat(build): build library using bili (#49)
adds new build process and new exports for cjs, umd and esm Co-authored-by: Matteo Gabriele <[email protected]>
1 parent f4c374d commit 1ce9812

7 files changed

+2081
-1412
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
coverage/

bili.config.dev.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { name } from "./package.json";
2+
3+
const config = {
4+
input: {
5+
[name]: "./src/index.js"
6+
},
7+
output: {
8+
dir: "./dist/",
9+
format: "esm"
10+
}
11+
};
12+
13+
export default config;

bili.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { name } from "./package.json";
2+
3+
const config = {
4+
input: {
5+
[name]: "./src/index.js"
6+
},
7+
output: {
8+
dir: "./dist/",
9+
format: ["esm", "cjs", "umd", "umd-min"],
10+
moduleName: "VueGtag"
11+
}
12+
};
13+
14+
export default config;

package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
},
1414
"scripts": {
1515
"commit": "git-cz",
16-
"build": "webpack --mode production",
17-
"dev": "webpack --mode development --watch",
18-
"lint": "eslint src --ext .js",
19-
"lint:fix": "eslint src --ext .js --fix",
16+
"clean": "del-cli dist",
17+
"prebuild": "yarn clean",
18+
"build": "bili",
19+
"dev": "bili --config bili.config.dev.js --watch",
20+
"lint": "eslint --ext .js .",
21+
"lint:fix": "yarn lint --fix",
2022
"test": "jest",
2123
"test:ci": "jest --coverage --bail --runInBand --verbose=false",
2224
"coverage": "jest --coverage",
2325
"coverage:html": "jest --coverage --coverageReporters=html",
2426
"coverage:text": "jest --coverage --coverageReporters=text",
2527
"coverage:lcov": "jest --coverage --coverageReporters=lcov",
26-
"prepublishOnly": "yarn lint && yarn test && webpack --mode production",
28+
"prepublishOnly": "yarn lint && yarn test && yarn build",
2729
"semantic-release": "semantic-release"
2830
},
2931
"config": {
@@ -54,7 +56,10 @@
5456
"vue",
5557
"vuejs"
5658
],
57-
"main": "dist/vue-gtag.js",
59+
"main": "./dist/vue-gtag.js",
60+
"module": "./dist/vue-gtag.esm.js",
61+
"unpkg": "./dist/vue-gtag.umd.js",
62+
"jsdelivr": "./dist/vue-gtag.umd.js",
5863
"types": "vue-gtag.d.ts",
5964
"files": [
6065
"dist",
@@ -69,26 +74,21 @@
6974
"@babel/preset-env": "^7.7.1",
7075
"@vue/test-utils": "^1.0.0-beta.29",
7176
"babel-eslint": "^10.0.3",
72-
"babel-loader": "^8.0.6",
73-
"clean-webpack-plugin": "^3.0.0",
77+
"bili": "^4.8.1",
7478
"commitizen": "^4.0.3",
75-
"compression-webpack-plugin": "^3.0.0",
7679
"cz-conventional-changelog": "^3.0.2",
80+
"del-cli": "^3.0.0",
7781
"eslint": "^6.6.0",
7882
"eslint-config-prettier": "^6.7.0",
79-
"eslint-loader": "^3.0.2",
8083
"eslint-plugin-jest": "^23.0.4",
8184
"eslint-plugin-prettier": "^3.1.1",
8285
"eslint-plugin-vue": "^6.0.1",
8386
"flush-promises": "^1.0.2",
8487
"jest": "^24.9.0",
8588
"prettier": "^1.19.1",
8689
"semantic-release": "^15.13.31",
87-
"terser-webpack-plugin": "^2.2.1",
8890
"vue": "^2.6.10",
8991
"vue-router": "^3.1.3",
90-
"vue-template-compiler": "^2.6.10",
91-
"webpack": "^4.41.2",
92-
"webpack-cli": "^3.3.10"
92+
"vue-template-compiler": "^2.6.10"
9393
}
9494
}

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import _bootstrap from "./bootstrap";
33
import api from "./api";
44

55
export default install;
6+
export { install };
67

78
export const bootstrap = _bootstrap;
89
export const setOptions = _setOptions;

webpack.config.js

-37
This file was deleted.

0 commit comments

Comments
 (0)