12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- const webpack = require('webpack')
- const fs = require('fs')
- const path = require('path')
- const dayjs = require('dayjs')
- const time = dayjs().format('YYYY-M-D HH:mm:ss')
- process.env.VUE_APP_UPDATE_TIME = time
- module.exports = {
- publicPath: process.env.VUE_APP_PUBLIC_PATH,
- lintOnSave: false,
- productionSourceMap: false,
- css: {
- loaderOptions: {
- less: {
- // globalVars: getLessVariables(path.resolve(__dirname, './src/assets/style/globalVars.less'))
- }
- }
- },
- configureWebpack: {
- plugins: [
- new webpack.ProvidePlugin({
- globalMapState: ['vuex', 'mapState'],
- globalMapMutations: ['vuex', 'mapMutations'],
- globalMapGetters: ['vuex', 'mapGetters'],
- globalConfig: ['/src/config.js', 'default'],
- globalApi: ['/src/api.js', 'default'],
- globalUtils: ['/src/utils/index.js', 'default'],
- }),
- ],
- },
- }
- function getLessVariables(file) {
- var themeContent = fs.readFileSync(file, 'utf-8')
- var variables = {}
- themeContent.split('\n').forEach(function(item) {
- if (item.indexOf('//') > -1 || item.indexOf('/*') > -1) {
- return
- }
- var _pair = item.split(':')
- if (_pair.length < 2) return
- var key = _pair[0].replace('\r', '').replace('@', '')
- if (!key) return
- var value = _pair[1].replace(';', '').replace('\r', '').replace(/^\s+|\s+$/g, '')
- variables[key] = value
- })
- return variables
- }
|