const DonePlugin = require("./src/plugin/webpackDonePlugin.js"); const WebpackBar = require("webpackbar"); const TerserPlugin = require("terser-webpack-plugin"); console.log('当前环境:', process.env.NODE_ENV); module.exports = { transpileDependencies: true, lintOnSave: false, chainWebpack: (config) => { config.module .rule("lottie") .test(/\.lottie$/) .use("file-loader") .loader("file-loader") .end(); config.plugin('html').tap(args => { args[0].title = "慧教研-大数据精准教学诊断平台"; return args }) }, publicPath: process.env.NODE_ENV === 'production' ? '/stu/' : '/',// /studata/ 生产环境(打包后)使用目标路径;/ 开发环境(npm run serve)使用根路径,不影响本地开发 configureWebpack: { optimization: { minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { compress: { drop_console: true,//// 移除所有 console.* drop_debugger: true,//// 移除所有 debugger.* pure_funcs: ["console.log"], }, }, }), ], }, name: "教学管理大数据平台", devtool: "source-map", // entry:'./public/index.html', // resolve:{}, // output:{ // filename:'[name].js', // chunkFilename:'[name].js' // }, plugins: [ new DonePlugin(), // new WebpackBar({ // basic: false, // name: 'JTZX-bigDataAdmin', // color: 'green' // }) ], }, // productionSourceMap: process.env.NODE_ENV !== 'production', productionSourceMap: false, // 生产环境关闭 sourceMap css: { extract: false, loaderOptions: { postcss: { // postcssOptions:{ // plugins: [ // require('postcss-pxtorem')({ // rootValue: 14.4, // 根据设计稿宽度计算,例如设计稿宽度为 1920px,则 rootValue = 1920 / 100 = 19.2 // propList: ['*'], // 需要转换的属性,* 表示所有属性 // selectorBlackList: [], // 忽略的选择器 // replace: false, // 替换 px 为 rem // mediaQuery: false, // 是否转换媒体查询中的 px // minPixelValue: 12 // 最小 px 值 // }) // ] // }, } }, }, devServer: { open: false, hot: true, host: "", port: 8080, https: false, client: { overlay: { warnings: false, errors: true, runtimeErrors: false, }, }, proxy: { "/api": { target: "https://dev3.k12100.net/student/api/", // target: "https://www.k12100.com/student/api/", changeOrigin: true, pathRewrite: { "^/api": "/", }, }, "/teachingApi": { target: "https://dev3.k12100.net/teaching/api/", changeOrigin: true, pathRewrite: { "^/teachingApi": "/", }, } }, }, };