40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
// const os = require('os')
|
|
// const networkInterfaces = os.networkInterfaces()
|
|
// const ip = networkInterfaces['以太网'][1] ? networkInterfaces['以太网'][1].address : networkInterfaces['以太网'][0].address
|
|
// console.log(ip)
|
|
|
|
// 生成时间戳,用于文件名版本控制
|
|
const timestamp = Date.now()
|
|
|
|
// 判断是否为生产环境
|
|
const isProduction = process.env.NODE_ENV === 'production'
|
|
|
|
module.exports = {
|
|
configureWebpack: config => {
|
|
// 基础配置
|
|
config.devtool = 'source-map'
|
|
|
|
// 仅在生产环境配置带时间戳的输出文件名
|
|
if (isProduction) {
|
|
config.output = {
|
|
...config.output,
|
|
filename: `js/[name].${timestamp}.[contenthash:8].js`,
|
|
chunkFilename: `js/[name].${timestamp}.[contenthash:8].js`
|
|
}
|
|
}
|
|
},
|
|
// CSS相关配置 - 也是更新用的 仅在生产环境使用
|
|
css: {
|
|
extract: isProduction ? {
|
|
filename: `css/[name].${timestamp}.[contenthash:8].css`,
|
|
chunkFilename: `css/[name].${timestamp}.[contenthash:8].css`
|
|
} : true
|
|
},
|
|
devServer: {
|
|
port: 8090,
|
|
host: '0.0.0.0',
|
|
https: false,
|
|
open: true
|
|
}
|
|
}
|