const DonePlugin = require("./src/plugin/webpackDonePlugin.js"); const WebpackBar = require("webpackbar"); const webpack = require('webpack'); const TerserPlugin = require("terser-webpack-plugin"); console.log('当前环境:', process.env.NODE_ENV); module.exports = { transpileDependencies: true, lintOnSave: false, chainWebpack: (config) => { config.plugin("provide").use(webpack.ProvidePlugin, [{ $: "jquery", jquery: "jquery", jQuery: "jquery", "window.jQuery": "jquery", },]); config.module .rule("lottie") .test(/\.lottie$/) .use("file-loader") .loader("file-loader") .end(); config.plugin('html').tap(args => { args[0].title = "慧教研-大数据精准教学诊断平台"; return args }) // 根据环境配置是否移除 console if (process.env.NODE_ENV === 'production') { config.optimization.minimizer('terser').tap((args) => { args[0].terserOptions.compress.drop_console = true; args[0].terserOptions.compress.drop_debugger = true; return args; }); } }, publicPath: process.env.NODE_ENV === 'production' ? '/stu/' : '/',// /studata/ 生产环境(打包后)使用目标路径;/ 开发环境(npm run serve)使用根路径,不影响本地开发 configureWebpack: { optimization: { minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { compress: { drop_console: process.env.NODE_ENV === 'production', // 只在生产环境移除 console drop_debugger: process.env.NODE_ENV === 'production', // 只在生产环境移除 debugger pure_funcs: process.env.NODE_ENV === 'production' ? ['console.log', 'console.info', 'console.warn', 'console.error'] : [], }, }, }), ], }, 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: "http://192.168.1.19:47003/api/",//静远本地 // target: "https://www.k12100.com/student/api/", changeOrigin: true, pathRewrite: { "^/api": "/", }, }, "/teachingApi": { target: "https://dev3.k12100.net/teaching/api/", changeOrigin: true, pathRewrite: { "^/teachingApi": "/", }, } }, }, };