123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- const path = require('path')
- const webpack = require('webpack')
- const packageJson = require('./package.json')
- 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: [
- '//cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js',
- '//cdn.jsdelivr.net/npm/vue-router@3.5.1/dist/vue-router.min.js',
- '//cdn.jsdelivr.net/npm/vuex@3.1.1/dist/vuex.min.js',
- '//cdn.jsdelivr.net/npm/axios@0.21.1/dist/axios.min.js'
- ]
- }
- const vueConfig = {
- configureWebpack: {
-
- plugins: [
-
- new webpack.IgnorePlugin({
- contextRegExp: /^\.\/locale$/,
- resourceRegExp: /moment$/
- }),
- new webpack.DefinePlugin({
- APP_VERSION: `"${packageJson.version}"`,
- GIT_HASH: JSON.stringify(getGitHash()),
- BUILD_DATE: buildDate
- })
- ]
-
-
-
- },
- chainWebpack: config => {
- config.resolve.alias.set('@$', resolve('src'))
-
- const svgRule = config.module.rule('svg')
-
- config.module.rules.delete('svg')
- config.module.rule('svg')
-
- .oneOf('svg_as_component')
- .resourceQuery(/inline/)
- .test(/\.(svg)(\?.*)?$/)
- .use('babel-loader')
- .loader('babel-loader')
- .end()
- .use('vue-svg-loader')
- .loader('vue-svg-loader')
- .options({
- svgo: {
- plugins: [
- { prefixIds: true },
- { cleanupIDs: true },
- { convertShapeToPath: false },
- { convertStyleToAttrs: true }
- ]
- }
- })
- .end()
- .end()
-
- .oneOf('svg_as_regular')
- .merge(svgRule.toConfig())
- .end()
-
-
-
-
-
-
-
-
-
- },
- css: {
- loaderOptions: {
- less: {
- modifyVars: {
-
-
-
- 'border-radius-base': '2px'
- },
-
- javascriptEnabled: true
- }
- }
- },
- devServer: {
-
- port: 8000
-
-
-
-
-
-
-
-
- },
-
- productionSourceMap: false,
- lintOnSave: undefined,
-
- transpileDependencies: []
- }
- if (process.env.VUE_APP_PREVIEW === 'true') {
-
- vueConfig.configureWebpack.plugins.push(createThemeColorReplacerPlugin())
- }
- module.exports = vueConfig
|