Moved userscript to client
This commit is contained in:
0
client/config/empty.cjs
Normal file
0
client/config/empty.cjs
Normal file
30
client/config/metadata.cjs
Normal file
30
client/config/metadata.cjs
Normal file
@@ -0,0 +1,30 @@
|
||||
const pkg = require('../package.json')
|
||||
|
||||
module.exports = {
|
||||
name: '3CX TAPI',
|
||||
namespace: 'http://cp-solutions.at',
|
||||
version: pkg.version,
|
||||
author: pkg.author,
|
||||
copyright: 'Copyright CP Solutions GmbH',
|
||||
source: pkg.repository.url,
|
||||
downloadURL: `${pkg.repository.url}/raw/branch/master/3CX_TAPI.user.js`,
|
||||
match: [
|
||||
'https://192.168.0.154:5001/*',
|
||||
'https://cpsolution.my3cx.at:5001/*'
|
||||
],
|
||||
require: [
|
||||
'https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@v1.2/waitForKeyElements.js',
|
||||
`https://cdn.jsdelivr.net/npm/axios@${pkg.dependencies.axios}/dist/axios.min.js`,
|
||||
`https://cdn.jsdelivr.net/npm/axios-userscript-adapter@${pkg.dependencies['axios-userscript-adapter']}/dist/axiosGmxhrAdapter.min.js`
|
||||
],
|
||||
grant: [
|
||||
'GM.xmlHttpRequest',
|
||||
'GM.notification',
|
||||
'GM.getValue',
|
||||
'GM.setValue'
|
||||
],
|
||||
connect: [
|
||||
'cpatapi.cpsrvweb2016.cp-austria.at'
|
||||
],
|
||||
'run-at': 'document-end'
|
||||
}
|
||||
51
client/config/webpack.config.base.cjs
Normal file
51
client/config/webpack.config.base.cjs
Normal file
@@ -0,0 +1,51 @@
|
||||
const path = require('path')
|
||||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
|
||||
|
||||
const webpackConfig = {
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts']
|
||||
},
|
||||
optimization: {
|
||||
minimize: false,
|
||||
moduleIds: 'named',
|
||||
},
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../dist')
|
||||
},
|
||||
externals: {
|
||||
jquery: '$',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
test: /\.js$/,
|
||||
},
|
||||
{
|
||||
test: /\.ts$/,
|
||||
loader: 'ts-loader'
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
'less-loader', // 将 Less 编译为 CSS
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: process.env.npm_config_report ? [new BundleAnalyzerPlugin()] : [],
|
||||
}
|
||||
|
||||
module.exports = webpackConfig
|
||||
37
client/config/webpack.config.dev.cjs
Normal file
37
client/config/webpack.config.dev.cjs
Normal 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
|
||||
19
client/config/webpack.config.production.cjs
Normal file
19
client/config/webpack.config.production.cjs
Normal 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
|
||||
Reference in New Issue
Block a user