dealer-management/vue.config.js

103 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// const { defineConfig } = require('@vue/cli-service')
// module.exports = defineConfig({
// transpileDependencies: true
// })
const { defineConfig } = require('@vue/cli-service')
const path = require('path')
const resolve = (dir) => path.join(__dirname, dir)
module.exports = defineConfig({
transpileDependencies: true,
publicPath: '/', // 署应用包时的基本 URL。 vue-router hash 模式使用
outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
lintOnSave: false, // eslint 检测
productionSourceMap: false, // 如果你不需要生产环境的 source map可以将其设置为 false 以加速生产环境构建。
devServer: {
hot: true,
compress: true,
historyApiFallback: true,
static: {
directory: path.join(__dirname, 'public')
},
port: 8080,
headers: {
'Access-Control-Allow-Origin': '*'
}
},
chainWebpack: (config) => {
config.resolve.alias
.set('@', resolve('src'))
.set('assets', resolve('src/assets'))
.set('api', resolve('src/api'))
.set('views', resolve('src/views'))
.set('components', resolve('src/components'))
}
})
// module.exports = defineConfig({
//
// publicPath: '/', // 应用程序域名后的根目录运行后为http://localhost:8081/ ,如果设置子路径为/myh5/ :http://10.29.0.20:8082/myh5/
// outputDir: 'dist', // 生成生产环境文件的目录,(打包后的文件存放目录)
// assetsDir: 'staticDir', // 防止生成的静态资源(js\css\img\fonts)(相对于outputDir的目录)
// indexPath: 'index.html', // 指定生成的index.html的输出路径在打包后也就是在dist文件中index.html生成的位置如果写成a/b/c.html,那生成的dist里面index.html就是dist/a/b/c.html
// filenameHashing: false, // 默认为true在打包之后生成的dist目录的静态资源的文件名会追加上hash值比如common.f151bhg.js,设置为false就不要hash
// // pages:{ // 多页模式下配置的,每个页面都有对应的条目文件,每个条目中都有entrytemplatefilenametitle和chunks和其他自定义添加的属性
// // index:{}
// // },
// lintOnSave: false, // 设置是否在开发环境下每次保存代码时都进行eslint验证
// // false关闭每次保存都进行检测
// // true开启每次保存都进行检测效果与warning一样
// // error开启每次保存都进行检测lint 错误将显示到浏览器页面上,且编译失败。
// // default同error
// // warning开启每次保存都进行检测lint 错误将显示到控制台命令行,而且编译并不会失败。
// // 所有 webpack-dev-server 的选项都支持
// devServer: { // 配置dev的服务器包括hostport热更新代理服务器配置等
// overlay: {
// warnings: false,
// errors: true
// },
// host: 'http://localhost:8081/',
// port: 8080,
// open: true, // 配置自动启动浏览器
// hotOnly: true, // 开启热更新
// disableHostCheck: true,
// proxy: {
// '/mall': {
// target: 'http://dev.baijin.com',
// changeOrigin: true,
// secure: false,
// pathRewrite: {
// '^/mall': '/mall'
// }
// }
// }
// },
// productionSourceMap: false, // 如果你不需要生产环境的 source map可以将其设置为 false 以加速生产环境构建。
// // configureWebpack 和 chainWebpack 的作用相同(都是修改webpack的默认配置),唯一的区别就是它们修改 webpack 配置的方式不同:
// // ①chainWebpack 通过链式编程的形式,来修改默认的 webpack 配置
// // ②configureWebpack 通过操作对象的形式,来修改默认的 webpack 配置
// configureWebpack: {
// },
// css: { // css
// // modules:false, //启用css的模块化?后面被requireModuleExtension属性替代
// // 为所有的 CSS 及其预处理文件开启 CSS Modules。
// // 这个选项不会影响 `*.vue` 文件。
// requireModuleExtension: true,
// extract: false, // 使用css分离插件 ExtractTextPlugin?生产环境下是true,开发环境下是false
// sourceMap: false, // 开启 CSS source maps?
// loaderOptions: { // 将选项传递给预加载程序处理器
// css: {}, // 这里的选项会传递给 css-loader
// postcss: {} // 这里的选项会传递给 postcss-loader
// } // css预设器配置项
// },
// // 是否为 Babel 或 TypeScript 使用 thread-loader。
// // 该选项在系统的 CPU 有多于一个内核时自动启用,仅作用于生产构建
// parallel: require('os').cpus().length > 1,
// // 向 PWA 插件传递选项
// pwa: {},
// // 可以用来传递任何第三方插件选项
// pluginOptions: {},
// // babel是一个编译器主要作用是将ECMAScript 2015+版本的代码转换为向后兼容的js语法
// // 因为Vue项目中普遍使用ES6语法若要求兼容低版本浏览器就需要引入babel将ES6转换为E5
// babel: {}
// })