Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 优化构建脚本 #75

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

## Contributors

|[<img src="https://avatars.githubusercontent.com/u/6828924?v=4" width="100px;"/><br/><sub><b>vagusX</b></sub>](https://github.com/vagusX)<br/>|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/71264455?v=4" width="100px;"/><br/><sub><b>TbabmBarry</b></sub>](https://github.com/TbabmBarry)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|
| :---: | :---: | :---: | :---: |
|[<img src="https://avatars.githubusercontent.com/u/6828924?v=4" width="100px;"/><br/><sub><b>vagusX</b></sub>](https://github.com/vagusX)<br/>|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/71264455?v=4" width="100px;"/><br/><sub><b>TbabmBarry</b></sub>](https://github.com/TbabmBarry)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|[<img src="https://avatars.githubusercontent.com/u/50158871?v=4" width="100px;"/><br/><sub><b>moshangqi</b></sub>](https://github.com/moshangqi)<br/>|
| :---: | :---: | :---: | :---: | :---: |


This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Jul 27 2023 19:43:37 GMT+0800`.
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Wed Aug 02 2023 20:13:17 GMT+0800`.

<!-- GITCONTRIBUTOR_END -->

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ $ npm run release

## Contributors

|[<img src="https://avatars.githubusercontent.com/u/6828924?v=4" width="100px;"/><br/><sub><b>vagusX</b></sub>](https://github.com/vagusX)<br/>|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/71264455?v=4" width="100px;"/><br/><sub><b>TbabmBarry</b></sub>](https://github.com/TbabmBarry)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|
| :---: | :---: | :---: | :---: |
|[<img src="https://avatars.githubusercontent.com/u/6828924?v=4" width="100px;"/><br/><sub><b>vagusX</b></sub>](https://github.com/vagusX)<br/>|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/71264455?v=4" width="100px;"/><br/><sub><b>TbabmBarry</b></sub>](https://github.com/TbabmBarry)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|[<img src="https://avatars.githubusercontent.com/u/50158871?v=4" width="100px;"/><br/><sub><b>moshangqi</b></sub>](https://github.com/moshangqi)<br/>|
| :---: | :---: | :---: | :---: | :---: |


This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Jul 27 2023 19:43:37 GMT+0800`.
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Wed Aug 02 2023 20:13:17 GMT+0800`.

<!-- GITCONTRIBUTOR_END -->

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
"scripts": {
"pack-zip": "sh ./scripts/build-zip.sh",
"pack-crx": "node ./scripts/build-crx.js && sh ./scripts/zip-crx.sh",
"preset-editor": "node ./scripts/preset-editor.js",
"bundle": "NODE_ENV=production webpack --mode=production",
"build": "npm run bundle && npm run preset-editor && npm run pack-zip && npm run pack-crx",
"build": "npm run bundle && npm run pack-zip && npm run pack-crx",
"contributor": "git-contributor",
"dev": "npm run preset-editor && NODE_ENV=development webpack --mode=development",
"dev": "NODE_ENV=development webpack --mode=development",
"docs:dev": "vuepress dev docs",
"type:check": "tsc --noEmit",
"lint:js": "eslint . --fix",
Expand Down
12 changes: 8 additions & 4 deletions scripts/preset-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ async function downloadFile(remoteURL, localFilename) {

const urls = Object.values(AssetsURL);

async function main() {
module.exports.webpackCleanIgnorePatterns = urls
.map(url => url.split('/').pop())
.map(fileName => `!${fileName}`);

module.exports.presetEditor = async function main() {
console.log('start preset editor ...');

for (let i = 0; i < urls.length; i++) {
const url = urls[i];
const fileName = url.split('/').pop();
const localFilename = path.resolve(distFolder, fileName);
await downloadFile(url, localFilename);
}
}

main().catch(console.log);
};
16 changes: 14 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const { presetEditor, webpackCleanIgnorePatterns } = require('./scripts/preset-editor');
const srcPath = path.resolve(__dirname, 'src');
const distPath = path.resolve(__dirname, 'dist');
const pagesPath = path.resolve(srcPath, 'pages');
Expand Down Expand Up @@ -69,7 +70,13 @@ const plugins = [
];

if (isProd) {
plugins.unshift(new CleanWebpackPlugin({ verbose: true }));
plugins.unshift(new CleanWebpackPlugin({
verbose: true,
cleanOnceBeforeBuildPatterns: [
'**/*',
...webpackCleanIgnorePatterns,
],
}));
}

const entry = {
Expand Down Expand Up @@ -216,4 +223,9 @@ const options = {
},
};

module.exports = options;

module.exports = async () => {
await presetEditor();

return options;
};
Loading