代码拉取完成,页面将自动刷新
同步操作将从 开店星开源商城/开店星公众版-uniapp源码 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//vue.config.js
const path = require('path')
const version = new Date().getTime()
const outDir = 'static/dist/shop_wap/'
let settings = require('./src/static/settings.js').config
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
function resolve(dir) {
return path.join(__dirname, dir);
}
const myPlugin = require('./webpackPlugins.js')
const CopyWebpackPlugin = require('copy-webpack-plugin');
// 定义webpack插件
let plugins = [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true)
})
]
// 不是开发环境
if (process.env.NODE_ENV !== 'development') {
if (process.env.UNI_PLATFORM === 'h5') {
// 如果是h5平台处理静态文件
plugins.push(
new CopyWebpackPlugin([
{
from: resolve('./src/static'),
to: resolve('./dist/build/h5/' + outDir)
}
])
);
plugins.push(new myPlugin.H5Plugin());
} else if (process.env.UNI_PLATFORM === 'mp-weixin') {
// 如果是微信小程序,处理配置文件
plugins.push(new myPlugin.MpWeixinPlugin());
}
}
function fmtUrl(url = '') {
return url.replace('.[contenthash:8]', '');
}
module.exports = {
transpileDependencies: ['uni-simple-router'],
assetsDir: outDir,
publicPath: '/',
filenameHashing: true,
productionSourceMap: false,
// 使用这个插件
configureWebpack: {
plugins: plugins,
externals: {
// 'vue': 'Vue',
// 'vuex': 'Vuex',
// 'axios': 'axios',
}
},
devServer: {
disableHostCheck: true,
/* 设置为0.0.0.0则所有的地址均能访问 */
host: '0.0.0.0',
port: 8081,
https: false,
hotOnly: false,
/* 使用代理 */
proxy: {
'/api': {
/* 目标代理服务器地址 */
target: settings.base_url,
/* 允许跨域 */
pathRewrite: {
'^/api': ''
},
changeOrigin: true
}
}
},
chainWebpack: config => {
config.plugins.delete('prefetch');
let filename = '',
chunkFilename = '';
if (process.env.UNI_PLATFORM === 'h5') {
config.plugins.delete('named-chunks');
config.plugins.delete('pwa');
filename = fmtUrl(config.output.store.get('filename')) + '?v=' + version;
chunkFilename = fmtUrl(config.output.store.get('chunkFilename')) + '?v=' + version;
} else {
filename = config.output.store.get('filename') + '?v=' + version;
chunkFilename = config.output.store.get('chunkFilename') + '?v=' + version;
}
config.output.store.set('filename', outDir + filename);
config.output.store.set('chunkFilename', outDir + chunkFilename);
config.resolve.alias.set('@', resolve('./src'));
config.module.rule('images').test(/\.(png|jpe?g|gif|webp)(\?.*)?$/).use('url-loader').loader('file-loader').options({
name: outDir + 'image/[name].[ext]'
});
config.module.rule('svg').test(/\.(svg)(\?.*)?$/).use('file-loader').loader('file-loader').options({
name: outDir + 'image/[name].[ext]'
});
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。