123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- const autoprefixer = require("autoprefixer");
- const pxtorem = require("postcss-pxtorem");
- const path = require('path');
- const themePath = path.resolve(__dirname,'src/assets/style/theme.less');
- const Timestamp = new Date().getTime();
- // var ip = '47.101.180.183'
- // var ip = '47.100.37.243'
- //var ip = '192.168.2.12'
- //var ip = '192.168.2.12'
- // var ip = '127.0.0.1'
- var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
- for (var i in ifaces) {
- for (var j in ifaces[i]) {
- var val = ifaces[i][j]
- if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
- ip = val.address
- }
- }
- }
- module.exports = {
- runtimeCompiler: true,
- // 关闭eslint检查
- lintOnSave: false,
-
- // 配置css前缀,px转rem
- css: {
- loaderOptions: {
- less: {
- modifyVars: {
- hack: `true; @import "${themePath}";`
- }
- },
- postcss: {
- plugins: [
- autoprefixer(),
- pxtorem({
- rootValue: 37.5,
- propList: ["*"]
- })
- ]
- }
- }
- },
- configureWebpack: {
- externals: {
- axios: "axios" // 配置使用CDN
- },
- },
- devServer: {
- open: true, //是否自动弹出浏览器页面
- port: '10087',
- https: false,
- hotOnly: false,
- // 代理
- proxy: {
- // 只要请求地址有'api'都会匹配上
- "/api": {
- target: "http://"+ip+":10010",
- ws: true,
- // 允许跨域
- changeOrigin: true,
- pathRewrite: {
- "^/api": "" //通过pathRewrite重写地址,将前缀/api转为/
- }
- }
- }
- },
- configureWebpack: { // webpack 配置
- output: { // 输出重构 打包编译后的 文件名称 【模块名称.时间戳】
- filename: `static/js/[name].${Timestamp}.js`,
- chunkFilename: `static/js/[name].${Timestamp}.js`
- },
- },
- };
|