Files
MES_Manage_View_V20/build/webpack.dev.conf.js
MESWORK 885e70b9fc init: MES_Manage_View_V20 v1.1.0 项目初始化
- Vue 2.7 + Element UI + Webpack 5 前端
- SQL Server 数据库脚本 (script.sql)
- 4份技术文档 (技术分析/功能映射/使用说明书/用户操作手册)
- 存储过程修复 (fix_生产管理_外协报表_查询.sql)
2026-05-21 09:31:44 +08:00

108 lines
3.0 KiB
JavaScript

'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const { merge } = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ESLintPlugin = require('eslint-webpack-plugin')
const portfinder = require('portfinder')
const CopyWebpackPlugin = require('copy-webpack-plugin')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
stats: 'errors-warnings',
infrastructureLogging: {
level: 'warn'
},
devtool: 'eval-cheap-module-source-map',
cache: {
type: 'filesystem',
buildDependencies: {
config: [__filename]
}
},
devServer: {
https: true,
historyApiFallback: true,
hot: true,
compress: true,
host: process.env.HOST || config.dev.host,
port: process.env.PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
static: {
publicPath: config.dev.assetsPublicPath,
watch: true
},
client: {
logging: 'warn',
overlay: config.dev.errorOverlay ? { errors: true, warnings: false } : false
},
proxy: config.dev.proxyTable
},
plugins: [
new webpack.ProgressPlugin({
activeModules: true, // 设置为 true 会显示当前正在处理的模块,但可能会影响性能
entries: true, // 显示条目计数
handler: (percentage, message, ...args) => {
// 一个简单的自定义处理函数,输出到控制台
console.log(`构建进度: ${(percentage * 100).toFixed(2)}% ${message}`);
}
}),
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
globOptions: {
ignore: ['.*']
}
}
]
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon: resolve('favicon.ico'),
title: '数据分析处理平台',
BASE_URL: 'static'
}),
...(config.dev.useEslint ? [new ESLintPlugin({
extensions: ['js', 'vue'],
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
})] : [])
],
optimization: {
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
minimize: false
}
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
devWebpackConfig.devServer.port = port
process.env.PORT = port
console.log(`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`)
resolve(devWebpackConfig)
}
})
})