generated from trim21/webpack-userscript-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7798a8d
Showing
22 changed files
with
4,032 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[*] | ||
charset=utf-8 | ||
end_of_line=lf | ||
trim_trailing_whitespace=true | ||
insert_final_newline=true | ||
indent_style=space | ||
indent_size=4 | ||
|
||
[{.babelrc,.stylelintrc,.eslintrc,jest.config,*.bowerrc,*.jsb3,*.jsb2,*.json,*.yaml,*.yml}] | ||
indent_style=space | ||
indent_size=2 | ||
|
||
[{*.js,*.vue,*.ts,*.cjs,.swcrc}] | ||
indent_style=space | ||
indent_size=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": ["schedule:monthly", ":masterIssue", "config:base"], | ||
"prHourlyLimit": 0, | ||
"lockFileMaintenance": { | ||
"extends": ["schedule:weekly"], | ||
"automerge": true, | ||
"enabled": true | ||
}, | ||
"automerge": true, | ||
"postUpdateOptions": ["npmDedupe"], | ||
"separateMajorMinor": false, | ||
"updateNotScheduled": false, | ||
"rangeStrategy": "bump" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- gh-pages | ||
- "renovate/**" | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "lts/*" | ||
cache: "npm" | ||
|
||
- run: npm ci | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# this workflow build from master branch and upload dist directory to "preview-dist" branch | ||
# remove this if you don't need it. | ||
|
||
name: deploy-preview | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "lts/*" | ||
cache: "npm" | ||
|
||
- run: npm ci | ||
- run: npm run build | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist | ||
publish_branch: preview-dist | ||
commit_message: deploy ${{ github.ref }} | ||
enable_jekyll: true | ||
user_name: github-actions[bot] | ||
user_email: github-actions[bot]@users.noreply.github.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# build latest v* tag and upload dist diectory to gh-pages branch. | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- v* | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "lts/*" | ||
cache: "npm" | ||
|
||
- run: npm ci | ||
- run: npm run build | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist | ||
enable_jekyll: true | ||
commit_message: deploy ${{ github.ref }} | ||
user_name: github-actions[bot] | ||
user_email: github-actions[bot]@users.noreply.github.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.idea | ||
.vscode | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2020-2022 Trim21 <[email protected]> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* This is an empty javascript file for webpack to generate a development UserScript without real code. | ||
* So we could make UserScript manager load script file from local file path. | ||
* See webpack.config.dev.js for more details. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { | ||
author, | ||
dependencies, | ||
repository, | ||
version, | ||
} = require("../package.json"); | ||
|
||
module.exports = { | ||
name: { | ||
$: "webpack-userscript-template", | ||
cn: "中文名", | ||
en: "english name", | ||
}, | ||
namespace: "https://trim21.me/", | ||
version: version, | ||
author: author, | ||
source: repository.url, | ||
// 'license': 'MIT', | ||
match: ["*://www.example.com/", "*://example.com/*"], | ||
require: [ | ||
`https://cdn.jsdelivr.net/npm/jquery@${dependencies.jquery}/dist/jquery.min.js`, | ||
], | ||
grant: ["GM.xmlHttpRequest"], | ||
connect: ["httpbin.org"], | ||
"run-at": "document-end", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const path = require("path"); | ||
|
||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); | ||
|
||
const webpackConfig = { | ||
resolve: { | ||
extensions: [".js", ".ts"], | ||
}, | ||
optimization: { | ||
minimize: false, | ||
moduleIds: "named", | ||
}, | ||
entry: "./src/index.ts", | ||
output: { | ||
path: path.resolve(__dirname, "../dist"), | ||
}, | ||
target: "web", | ||
externals: { | ||
jquery: "$", | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.m?ts$/, | ||
use: { | ||
loader: "ts-loader", | ||
}, | ||
}, | ||
{ | ||
test: /\.less$/, | ||
use: ["style-loader", "css-loader", "less-loader"], | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: ["style-loader", "css-loader"], | ||
}, | ||
], | ||
}, | ||
plugins: process.env.npm_config_report ? [new BundleAnalyzerPlugin()] : [], | ||
}; | ||
|
||
module.exports = webpackConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const path = require("path"); | ||
const { merge } = require("webpack-merge"); | ||
const LiveReloadPlugin = require("webpack-livereload-plugin"); | ||
const { | ||
UserScriptMetaDataPlugin, | ||
} = require("userscript-metadata-webpack-plugin"); | ||
|
||
const metadata = require("./metadata.cjs"); | ||
const webpackConfig = require("./webpack.config.base.cjs"); | ||
|
||
metadata.require.push( | ||
"file://" + path.resolve(__dirname, "../dist/index.debug.js") | ||
); | ||
|
||
const cfg = merge(webpackConfig, { | ||
mode: "development", | ||
cache: { | ||
type: "filesystem", | ||
name: "dev", | ||
}, | ||
entry: { | ||
debug: webpackConfig.entry, | ||
"dev.user": path.resolve(__dirname, "./empty.cjs"), | ||
}, | ||
output: { | ||
filename: "index.[name].js", | ||
path: path.resolve(__dirname, "../dist"), | ||
}, | ||
devtool: "eval-source-map", | ||
watch: true, | ||
watchOptions: { | ||
ignored: /node_modules/, | ||
}, | ||
plugins: [ | ||
new LiveReloadPlugin({ | ||
delay: 500, | ||
}), | ||
new UserScriptMetaDataPlugin({ | ||
metadata, | ||
}), | ||
], | ||
}); | ||
|
||
module.exports = cfg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const { merge } = require("webpack-merge"); | ||
const { | ||
UserScriptMetaDataPlugin, | ||
} = require("userscript-metadata-webpack-plugin"); | ||
|
||
const metadata = require("./metadata.cjs"); | ||
const webpackConfig = require("./webpack.config.base.cjs"); | ||
|
||
const cfg = merge(webpackConfig, { | ||
mode: "production", | ||
output: { | ||
filename: "index.prod.user.js", | ||
}, | ||
optimization: { | ||
// if you need minimize, you need to config minimizer to keep all comments | ||
// to keep userscript meta. | ||
minimize: false, | ||
}, | ||
cache: { | ||
type: "filesystem", | ||
name: "prod", | ||
}, | ||
plugins: [ | ||
new UserScriptMetaDataPlugin({ | ||
metadata, | ||
}), | ||
], | ||
}); | ||
|
||
module.exports = cfg; |
Oops, something went wrong.