| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- const path = require("path");
- const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
- const AutoDllPlugin = require("autodll-webpack-plugin");
- function resolve(dir) {
- return path.join(__dirname, dir);
- }
- module.exports = {
- assetsDir: "./h5",
- publicPath: "./",
- outputDir: "cordova/www",
- configureWebpack: config => {
- Object.assign(config.resolve.alias, {
- "@utils": resolve("src/utils"),
- "@libs": resolve("src/libs"),
- "@api": resolve("src/api"),
- "@components": resolve("src/components"),
- "@assets": resolve("src/assets"),
- "@css": resolve("src/assets/css"),
- "@images": resolve("src/assets/images"),
- "@views": resolve("src/views"),
- "@mixins": resolve("src/mixins")
- });
- if (process.env.NODE_ENV !== "production") {
- config.plugins.push(
- new HardSourceWebpackPlugin(),
- new AutoDllPlugin({
- inject: true,
- debug: true,
- filename: "[name]_[hash].js",
- path: "./dll" + Date.parse(new Date()),
- entry: {
- vendor_vue: ["vue", "vuex", "vue-router"],
- vendor_ui: ["vue-awesome-swiper", "vue-ydui"],
- vendor_tools: ["axios", "core-js"]
- }
- })
- );
- }
- },
- chainWebpack: config => {
- config.plugin("html").tap(args => {
- args[0].VUE_APP_NAME = "美天旺";
- return args;
- });
- },
- devServer: {
- host: "localhost", //target host
- port: 8080,
- //proxy:{'/api':{}},代理器中设置/api,项目中请求路径为/api的替换为target
- proxy: {
- "/api": {
- target: "http://twong.h", //代理地址,这里设置的地址会代替axios中设置的baseURL
- changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
- //ws: true, // proxy websockets
- //pathRewrite方法重写url
- pathRewrite: {
- "^/api": "/api"
- //pathRewrite: {'^/api': '/'} 重写之后url为 http://192.168.1.16:8085/xxxx
- //pathRewrite: {'^/api': '/api'} 重写之后url为 http://192.168.1.16:8085/api/xxxx
- }
- }
- }
- }
- };
|