Commit 47a0d034 by xinlaa

移动端增加初始配置

1 parent 8279acdb
{
"name": "link-wechat-mobile",
"version": "0.1.0",
"private": true,
"description": "LinkWeChat mobile",
"license": "GPL-3.0",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
......@@ -26,9 +27,13 @@
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
"html-webpack-plugin": "^4.5.1",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"prettier": "^1.19.1",
"script-ext-html-webpack-plugin": "^2.1.5",
"style-resources-loader": "^1.3.2",
"vue-cli-plugin-style-resources-loader": "~0.1.4",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
......
import wx from '@/utils/jweixin-1.2.0.js'
import Vue from 'vue'
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)
import App from './App.vue'
import router from './router'
import store from './store'
......
const path = require('path')
const resolve = (dir) => {
return path.join(__dirname, dir)
}
process.env.VUE_APP_TITLE = require('./package.json').description
// 项目部署基础
// 默认情况下,我们假设你的应用将被部署在域的根目录下,
// 例如:https://www.my-app.com/
// 默认:'/'
// 如果您的应用程序部署在子路径中,则需要在这指定子路径
// 例如:https://www.my-app.com/my-app/
// 需要将它改为'/my-app/'
const BASE_URL = process.env.NODE_ENV === 'development' ? '/' : '/mobile'
module.exports = {
publicPath: BASE_URL,
outputDir: 'mobile', // 打包名称
// 打包时不生成.map文件
productionSourceMap: false,
// 如果你不需要使用eslint,把lintOnSave设为false即可
lintOnSave: false,
// 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
devServer: {
host: '0.0.0.0',
port: 8082,
// 自动打开浏览器
open: true,
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
['http']: {
target: process.env.VUE_APP_BASE_API,
changeOrigin: true,
// pathRewrite: {
// ['^' + process.env.VUE_APP_BASE_API]: ''
// }
},
},
disableHostCheck: true,
},
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [path.resolve(__dirname, './src/styles/varibles.less')],
},
},
configureWebpack: {
resolve: {
alias: {
'@': resolve('src'),
},
},
},
chainWebpack(config) {
config.plugin('preload').tap(() => [
{
rel: 'preload',
// to ignore runtime.js
fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
include: 'initial',
},
])
config.when(process.env.NODE_ENV !== 'development', (config) => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [
{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/,
},
])
.end()
config.optimization.minimizer('terser').tap((options) => {
options[0].terserOptions.compress.drop_console = true
options[0].terserOptions.compress.drop_debugger = true
return options
})
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-vant', // split vant 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[\\/]_?vant(.*)/, // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true,
},
},
})
config.optimization.runtimeChunk('single')
})
},
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!