123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- const path = require('path')
- const version = require('./package.json').version
- const fs = require('fs')
- const NODE_ENV = process.env.NODE_ENV
- let publicPath = '/flowablePc/'
- let outputDir = 'dist'
- let appFileName = 'Demo'
- if (NODE_ENV === 'lib') {
- const libVersionList = fs.readdirSync('./docs/lib')
- if (libVersionList.includes(version)) {
- console.log(libVersionList);
- console.log(version);
- throw new Error(`lib 版本 ${version} 已存在`)
- }
- publicPath = './'
- outputDir = `docs/lib/${version}`
- appFileName = 'Lib'
- }
- /* const mainFileStr = `
- import Vue from 'vue'
- import App from './${appFileName}.vue'
- import ElementUI from 'element-ui'
- import 'element-ui/lib/theme-chalk/index.css'
- Vue.config.productionTip = false
- Vue.use(ElementUI)
- new Vue({
- render: h => h(App)
- }).$mount('#app')
- `
- fs.writeFileSync('./src/main.js', mainFileStr) */
- const resolve = dir => {
- return path.join(__dirname, dir)
- }
- module.exports = {
- css: {
- loaderOptions: {
- sass: {
- // 配置全局样式变量
- }
- }
- },
- publicPath: publicPath,
- outputDir: outputDir,
- // tweak internal webpack configuration.
- // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
- // 如果你不需要使用eslint,把lintOnSave设为false即可
- lintOnSave: true,
- chainWebpack: config => {
- config.module
- .rule('svg')
- .exclude.add(resolve('src/icons'))
- .end()
- config.module
- .rule('icons')
- .test(/\.svg$/)
- .include.add(resolve('src/icons'))
- .end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
- .options({
- symbolId: 'icon-[name]'
- })
- .end()
-
- config.resolve.alias
- .set('views', resolve('src/views'))
- config
- .when(NODE_ENV !== 'development' && NODE_ENV !== 'build',
- config => {
- config
- .optimization.splitChunks({
- chunks: 'all',
- cacheGroups: {
- libs: {
- name: 'chunk-libs',
- test: /[\\/]node_modules[\\/]/,
- priority: 10,
- chunks: 'initial' // only package third parties that are initially dependent
- },
- elementUI: {
- name: 'chunk-elementUI', // split elementUI into a single package
- priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
- test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
- },
- vue: {
- name: 'chunk-vue', // split elementUI into a single package
- priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
- test: /[\\/]node_modules[\\/]_?vue(.*)/ // in order to adapt to cnpm
- }
- }
- })
- config.optimization.runtimeChunk('single')
- }
- )
- },
- // 设为false打包时不生成.map文件
- productionSourceMap: true,
- // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
- devServer: {
- disableHostCheck: true,
- proxy: {
- '/api': {
- // 此处的写法,目的是为了 将 /api 替换成 https://www.baidu.com/
- target: 'http://127.0.0.1:7001/',
- // 允许跨域
- changeOrigin: true,
- ws: true,
- // pathRewrite: {
- // '^/api': '/flowable'
- // }
-
- }
- }
- }
- }
|