const path = require("path"); function resolve(dir) { return path.join(__dirname, dir); } const isDev = process.env.NODE_ENV !== "production"; module.exports = { publicPath: "./", //部署应用时的根路径(默认'/'),也可用相对路径(存在使用限制) outputDir: "dist", //运行时生成的生产环境构建文件的目录(默认'dist',构建之前会被清除) assetsDir: "", //静态资源目录(js、css、img、fonts),相对outputDir的目录(默认'') indexPath: "index.html", //指定生成index.html的输出路径(相对outputDir)也可以是绝对路径 lintOnSave: false, //是否开启ESlint(保存时检查) configureWebpack: { //配置路径 resolve: { alias: { "@": resolve("/src"), "@assets": resolve("/src/assets"), "@public": resolve("/public") }, extensions: [".js", ".json", ".css", ".scss", ".vue"] }, externals: { //采用地址栏的方式来引用 vue: "Vue", axios: "axios" } // entry: { // app: ["@babel/polyfill", "./src/main.js"], // }, }, productionSourceMap: false, //生产环境是否生成 sourceMap 文件 pages: { //pages里配置的路径和文件名在你的文档目录必须存在,否则启动服务会报错 index: { //除了 entry 之外都是可选的 entry: "src/main.js", //page的主入口 template: "public/index.html", //模板来源 filename: "index.html", //在 dist/index.html 的输出 //title在template中使用:<%=htmlWebpackPlugin.options.title%> title: "beschool", chunks: ["chunk-vendors", "chunk-common", "index"] // 在这个页面中包含的块,默认情况下会包含,提取出来的通用 chunk 和 vendor chunk } //subpage: 'src/main.js' //官方解释:当使用只有入口的字符串格式时,模板会被推导为public/subpage.html //若找不到就回退到public/index.html,输出文件名会被推导为subpage.html }, css: { extract: !isDev, //是否使用css分离插件 ExtractTextPlugin sourceMap: isDev, //开启 CSS source maps // modules: false, //启用CSS modules for all css / pre-processor files. requireModuleExtension: true, //与modules相反 loaderOptions: { //css预设器配置项 sass: { // prependData: `@import "@assets/styles/varible.scss";`, } /* postcss: { plugins: [ require('postcss-pxtorem')({ rootValue: 37.5, // 换算的基数 selectorBlackList: [], // 忽略转换正则匹配项 propList: ['*'], }), ] } */ } }, devServer: { //环境配置 host: "localhost", port: 8088, https: false, //是否开启https hotOnly: true, //是否配置热更新 open: true, //配置自动启动浏览器 // 主题通道 dev 代理(A 类接入 §2.2 第一步): // 本地开发时 /static/* 兜到主题通道(默认线上通道),联调本地通道源可覆盖: // YH_THEME_PROXY_TARGET=http://localhost:9527 npm run dev // 生产与通道同源,不依赖本代理。 proxy: { "/static": { target: process.env.YH_THEME_PROXY_TARGET || "http://base.yunhaixingtong.com", changeOrigin: true, ws: true } // 原有业务接口代理示例(按需启用): // '/api': { // target: 'http://basedebug.bestsch.com/BschHome', // ws: true, //是否跨域 // changeOrigin: true, // // pathRewrite: { '^/api': '' } // } }, overlay: { //关闭eslint warnings: false, errors: false } }, pluginOptions: { // 第三方插件配置 // ... }, transpileDependencies: [ "view-design" // "vue-grid-layout", // "vue-grid-layout.common.js" ] //ie兼容相关 };