123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- const path = require('path')
- const webpack = require('webpack')
- const GitRevisionPlugin = require('git-revision-webpack-plugin')
- const GitRevision = new GitRevisionPlugin()
- const buildDate = JSON.stringify(new Date().toLocaleString())
- const createThemeColorReplacerPlugin = require('./config/plugin.config')
- function resolve (dir) {
- return path.join(__dirname, dir)
- }
- function getGitHash () {
- try {
- return GitRevision.version()
- } catch (e) {}
- return 'unknown'
- }
- const isProd = process.env.NODE_ENV === 'production'
- const assetsCDN = {
-
- externals: {
- vue: 'Vue',
- 'vue-router': 'VueRouter',
- vuex: 'Vuex',
- axios: 'axios'
- },
- css: [],
-
- js: [
- '//unpkg.zhimg.com/vue@2.6.10/dist/vue.min.js',
- '//unpkg.zhimg.com/vue-router@3.1.3/dist/vue-router.min.js',
- '//unpkg.zhimg.com/vuex@3.1.1/dist/vuex.min.js',
- '//unpkg.zhimg.com/axios@0.19.0/dist/axios.min.js'
- ]
- }
- const vueConfig = {
- configureWebpack: {
-
- plugins: [
-
- new webpack.IgnorePlugin({
- resourceRegExp: /^\.\/locale$/,
- contextRegExp: /moment$/
- }),
- new webpack.DefinePlugin({
- APP_VERSION: `"${require('./package.json').version}"`,
- GIT_HASH: JSON.stringify(getGitHash()),
- BUILD_DATE: buildDate
- })
- ],
-
- externals: isProd ? assetsCDN.externals : {}
- },
- chainWebpack: (config) => {
- config.resolve.alias
- .set('@$', resolve('src'))
- const svgRule = config.module.rule('svg')
- svgRule.uses.clear()
- svgRule
- .oneOf('inline')
- .resourceQuery(/inline/)
- .use('vue-svg-icon-loader')
- .loader('vue-svg-icon-loader')
- .end()
- .end()
- .oneOf('external')
- .use('file-loader')
- .loader('file-loader')
- .options({
- name: 'assets/[name].[hash:8].[ext]'
- })
-
-
- if (isProd) {
- config.plugin('html').tap(args => {
- args[0].cdn = assetsCDN
- return args
- })
- }
- },
- css: {
- loaderOptions: {
- less: {
- modifyVars: {
-
-
-
- 'border-radius-base': '2px'
- },
-
- javascriptEnabled: true
- }
- }
- },
- devServer: {
-
- port: 8000,
- proxy: {
-
- [process.env.VUE_APP_BASE_API]: {
-
-
- target:`http://192.168.31.129:8080/`,
- changeOrigin: true,
- pathRewrite: {
- ['^' + process.env.VUE_APP_BASE_API]: ''
- }
- }
- }
- },
-
- productionSourceMap: false,
- lintOnSave: undefined,
-
- transpileDependencies: []
- }
- if (process.env.VUE_APP_PREVIEW === 'true') {
- console.log('VUE_APP_PREVIEW', true)
-
- vueConfig.configureWebpack.plugins.push(createThemeColorReplacerPlugin())
- }
- module.exports = vueConfig
|