Skip to content

Commit

Permalink
added postbuild to generate package.json
Browse files Browse the repository at this point in the history
Leo-Nicolle committed Feb 14, 2022
1 parent 4230f23 commit 5b76c6c
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
},
"scripts": {
"serve": "VUE_CLI_SERVICE_CONFIG_PATH=demo-vue.config.js vue-cli-service serve",
"postbuild": "./scripts/post-build.js",
"build": "vue-cli-service build --target lib --name lib src/main.js",
"test:unit": "vue-cli-service test:unit --reporter mocha-multi-reporters --reporter-options configFile=.test-reporters.json",
"lint": "vue-cli-service lint",
26 changes: 26 additions & 0 deletions scripts/post-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/node

const fs = require("fs")

fs.readFile("./package.json", "utf8", (err, data) => {
if (err) {
throw err
}
const base = JSON.parse(data);
const overwrite = {
devDependencies:undefined,
scripts: undefined,
eslintConfig: undefined,
browserslist: undefined,
files: [
"./lib.umd.js",
"./lib.umd.js.map",
],
main: './lib.umd.js'
}
fs.writeFile('./dist/package.json', JSON.stringify({ ...base, ...overwrite }, null, 2), (err) => {
if (err) {
throw err
}
});
});

0 comments on commit 5b76c6c

Please sign in to comment.