123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- 'use strict'
- const path = require('path') // Node.js的path模块提供了一些用于处理文件路径的小工具
- const settings = require('./src/settings.js')
- const name = settings.title // 页面标题
- const port = process.env.port || process.env.npm_config_port || 8080 // dev端口号
- function resolve(dir) {
- return path.join(__dirname, dir) // 连接路径,会正确使用当前系统的路径分隔符,Unix系统是"/",Windows系统是"\"
- }
- // 所有配置项详情请前往 https://cli.vuejs.org/config 查看
- module.exports = {
- /**
- * 如果计划在子路径下部署站点,则需要设置publicPath
- * 例如,如果计划将站点部署到https://foo.github.io/bar/,那么publicPath应该设置为“/bar/”。在多数情况下,请使用“/”!!
- * 详情参考: https://cli.vuejs.org/config/#publicpath
- */
- publicPath: '',
- outputDir: 'dist',//输出目录
- assetsDir: 'static',//编译文件存放目录
- lintOnSave: process.env.NODE_ENV === 'development',//dev环境保存时eslint校验
- productionSourceMap: false,//prod环境不启用sourceMap
- devServer: {
- port: port,
- disableHostCheck: true,
- proxy: {
- '/api': {
- target:'http://192.168.0.131:8087/TransServlet',
- // target:'http://192.168.0.43:8087/TransServlet',
- //target:'http://192.168.0.103:8087/TransServlet',
- // target: 'http://localhost:8081/', // 后端接口地址
- // target: 'http://192.168.0.43:8081/',
- // target: 'http://192.168.0.43:8181/',
- // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
- secure: false, //接受使用https
- changeOrigin: true, //允许跨域
- ws: false, //使用websocket
- pathRewrite: { // 路径重写
- '^/api': ''
- }
- },
- '/file': {
- // target: 'http://192.168.0.15:8081/', // 后端接口地址
- target: 'http://192.168.0.131:8081/',
- //target: 'http://192.168.0.43:8081/',
- // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
- secure: false, //接受使用https
- changeOrigin: true, //允许跨域
- ws: false, //使用websocket
- pathRewrite: { // 路径重写
- '^/file': ''
- }
- },
- '/websokct':{
- target: 'http://192.168.0.131:8081/',
- // target: 'http://192.168.0.43:8081/',
- // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
- secure: false, //接受使用https
- }
- },
- open: false,//不自动打开浏览器
- overlay: {
- warnings: false,
- errors: true
- },
- // before: require('./mock/mock-server.js')
- },
- configureWebpack: {
- // 创建别名(在webpack的name字段中提供别名,以便在index.html中插入正确的引用路径)
- name: name,
- resolve: {
- alias: {
- '@': resolve('src')
- }
- }
- },
- chainWebpack(config) {
- config.plugins.delete('preload') // TODO: need test
- config.plugins.delete('prefetch') // TODO: need test
- // 设置 svg-sprite-loader 插件生效文件夹(src/icons)
- 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()
- // 设置 preserveWhitespace
- config.module
- .rule('vue')
- .use('vue-loader')
- .loader('vue-loader')
- .tap(options => {
- // options.compilerOptions.preserveWhitespace = true
- return options
- })
- .end()
- // config.module
- // .rule('THREE')
- // .use('imports-loader?THREE=three')
- // .loader('imports-loader')
- // .end()
- // config.module
- // .rule('OrbitControls”')
- // .use('exports-loader?THREE.OrbitControls')
- // .loader('exports-loader')
- // .end()
- // webpack的SourceMaps 7种打包编译模式详见 https://webpack.js.org/configuration/devtool/#development
- config
- .when(process.env.NODE_ENV === 'development',
- config => config.devtool('cheap-source-map') // 生成一个没有列信息(column-mappings)的SourceMaps文件,不包含loader的sourcemap(譬如babel的sourcemap)
- )
- config
- .when(process.env.NODE_ENV !== 'development',
- config => {
- config
- .plugin('ScriptExtHtmlWebpackPlugin')
- .after('html')
- .use('script-ext-html-webpack-plugin', [{
- // `runtime` 必须与runtimeChunk名称相同,默认值为`runtime`
- inline: /runtime\..*\.js$/
- }])
- .end()
- config
- .optimization.splitChunks({
- chunks: 'all',
- cacheGroups: {
- libs: {
- name: 'chunk-libs',
- test: /[\\/]node_modules[\\/]/,
- priority: 10,
- chunks: 'initial' // 仅打包最初的第三方依赖
- },
- elementUI: {
- name: 'chunk-elementUI', // 将elementUI拆分为一个包
- priority: 20, // weight必须大于libs和app,否则将打包成libs或app
- test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // 为了适应cnpm
- },
- commons: {
- name: 'chunk-commons',
- test: resolve('src/components'), // 可以自定义规则
- minChunks: 3, // 最小公共数
- priority: 5,
- reuseExistingChunk: true
- }
- }
- })
- config.optimization.runtimeChunk('single')
- }
- )
- }
- }
|