Userscript template aktualisiert

This commit is contained in:
2021-08-27 18:12:26 +02:00
parent fec9885a64
commit 4283ee6b5c
21 changed files with 9951 additions and 5850 deletions

View File

@ -5,9 +5,9 @@ module.exports = {
namespace: 'http://cp-solutions.at',
version: pkg.version,
author: pkg.author,
copyright: 'Copyright 2020 CP Solutions GmbH',
copyright: 'Copyright 2021 CP Solutions GmbH',
source: pkg.repository.url,
downloadURL: 'http://scootaloo.cp-austria.at/gitlist/3cx_tapi.git/raw/master/3CX_TAPI.user.js',
downloadURL: 'https://source.cp-austria.at/git/CPATRD/3cx_tapi/raw/branch/master/3CX_TAPI.user.js',
match: [
'https://192.168.0.154:5001/webclient*',
'https://cpsolution.my3cx.at:5001/webclient*'
@ -18,8 +18,10 @@ module.exports = {
`https://cdn.jsdelivr.net/npm/axios-userscript-adapter@${pkg.dependencies['axios-userscript-adapter']}/dist/axiosGmxhrAdapter.min.js`
],
grant: [
'GM_xmlhttpRequest',
'GM.notification'
'GM.xmlHttpRequest',
'GM.notification',
'GM.getValue',
'GM.setValue'
],
connect: [
'cpatapi.cpsrvweb2016.cp-austria.at'

View File

@ -1,42 +1,38 @@
const path = require('path')
const webpack = require('webpack')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const webpackConfig = {
node: {
Buffer: false
},
resolve: {
extensions: ['.js', '.ts']
},
// performance: {
// hints: false
// },
optimization: {
minimize: false
minimize: false,
moduleIds: 'named',
},
entry: './src/js/index.js',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, '../dist')
},
externals: {
jquery: '$',
axios: 'axios',
'axios-userscript-adapter': 'axiosGmxhrAdapter'
},
module: {
rules: [
{
use: {
loader: 'babel-loader',
},
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
},
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader'
},
{
test: /\.less$/,
loader: [
use: [
'style-loader',
'css-loader',
'less-loader', // 将 Less 编译为 CSS
@ -44,16 +40,14 @@ const webpackConfig = {
},
{
test: /\.css$/,
loader: [
use: [
'style-loader',
'css-loader',
]
}
]
},
plugins: [
new webpack.HashedModuleIdsPlugin()
]
plugins: process.env.npm_config_report ? [new BundleAnalyzerPlugin()] : [],
}
module.exports = webpackConfig

View File

@ -0,0 +1,37 @@
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.prod.user.js')
)
const cfg = merge(webpackConfig, {
entry: {
prod: webpackConfig.entry,
dev: path.resolve(__dirname, './empty.cjs'),
},
output: {
filename: 'index.[name].user.js',
path: path.resolve(__dirname, '../dist'),
},
devtool: 'inline-source-map',
watch: true,
watchOptions: {
ignored: /node_modules/,
},
plugins: [
new LiveReloadPlugin({
delay: 500,
}),
new UserScriptMetaDataPlugin({
metadata,
}),
],
})
module.exports = cfg

View File

@ -1,43 +0,0 @@
const path = require("path");
const { merge } = require("webpack-merge");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
const LiveReloadPlugin = require("webpack-livereload-plugin");
const UserScriptMetaDataPlugin = require("userscript-metadata-webpack-plugin");
const metadata = require("./metadata");
const webpackConfig = require("./webpack.config.base");
metadata.require.push(
"file://" + path.resolve(__dirname, "../dist/index.prod.user.js")
);
const cfg = merge(webpackConfig, {
entry: {
prod: webpackConfig.entry,
dev: path.resolve(__dirname, "./empty.js"),
},
output: {
filename: "index.[name].user.js",
path: path.resolve(__dirname, "../dist"),
},
devtool: "inline-source-map",
watch: true,
watchOptions: {
ignored: /node_modules/,
},
plugins: [
new LiveReloadPlugin({
delay: 500,
}),
new UserScriptMetaDataPlugin({
metadata,
}),
],
});
if (process.env.npm_config_report) {
cfg.plugins.push(new BundleAnalyzerPlugin());
}
module.exports = cfg;

View File

@ -0,0 +1,19 @@
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: metadata.name + '.prod.user.js',
},
plugins: [
new UserScriptMetaDataPlugin({
metadata,
}),
],
})
module.exports = cfg

View File

@ -1,23 +0,0 @@
const { merge } = require("webpack-merge");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const UserScriptMetaDataPlugin = require('userscript-metadata-webpack-plugin')
const metadata = require('./metadata')
const webpackConfig = require('./webpack.config.base')
const cfg = merge({}, webpackConfig, {
output: {
filename: 'index.prod.user.js'
},
plugins: [
new UserScriptMetaDataPlugin({
metadata
})
]
})
if (process.env.npm_config_report) {
cfg.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = cfg