NeteaseCloudMusicApiEnhanced/webpack.config.js
MoeFurina d8ecb31f7b
ci: Add webpack configuration and license file for bundle.js
- Created webpack.config.js to configure the build process for the application.
- Set entry point to app.js and output to precompiled/bundle.js.
- Excluded node_modules from the bundle and specified external dependencies.
- Added Babel loader for transpiling JavaScript files.
- Included a license file for regenerator-runtime in precompiled directory.
2026-01-31 13:35:04 +08:00

71 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const path = require('path');
module.exports = {
entry: './app.js',
target: 'node',
output: {
path: path.resolve(__dirname, 'precompiled'),
filename: 'bundle.js',
libraryTarget: 'commonjs2',
},
resolve: {
extensions: ['.js', '.json'],
},
// 排除所有node_modules中的依赖因为它们在运行时会被require
externals: [
// 项目依赖的所有外部模块
'express',
'fs',
'path',
'os',
'child_process',
'crypto-js',
'dotenv',
'express-fileupload',
'md5',
'music-metadata',
'node-forge',
'pac-proxy-agent',
'qrcode',
'safe-decode-uri-component',
'tunnel',
'xml2js',
'yargs',
'axios',
'@neteasecloudmusicapienhanced/unblockmusic-utils',
/\.node$/, // 排除.node文件
],
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
exclude: /node_modules/,
},
],
},
mode: 'production',
optimization: {
minimize: true,
},
stats: {
errorDetails: true
},
// 为动态模块提供上下文
plugins: [
new (require('webpack')).ContextReplacementPlugin(
/util[\/\\]request/, // 针对request模块路径
path.resolve(__dirname)
)
],
// 避免对Node.js内置模块的警告
node: {
__dirname: false,
__filename: false,
}
};