Rowrey 2019-08-25 23:14 采纳率: 0%
浏览 510

vue3.0 配置多页面后 骨架配置无效


let path = require('path')
let SkeletonWebpackPlugin = require('vue-skeleton-webpack-plugin')
module.exports = {
    lintOnSave: false, //禁用eslint
    baseUrl:process.env.NODE_ENV === "production"?'/':'/',
    productionSourceMap: false,
    pages:{ index: {
        // page 的入口
        entry: 'src/pages/index/index.js',
        // 模板来源
        template: 'src/pages/index/index.html',
        // 在 dist/index.html 的输出
        filename: 'index.html',
        // 当使用 title 选项时,
        // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
        title: 'Index Page'
        },
    },
    devServer: {
        index: 'index.html', //默认启动serve 打开page1页面
        open: process.platform === 'darwin',
        host: '',
        port: 8088,
        https: false,
        hotOnly: false,
        proxy: {
            '/xrf/': {
                target: 'http://www.baidu.com/',
                changeOrigin: true,
                pathRewrite: {
                    '^/xrf': ''
                }
            }
        }, // 设置代理
        // before: app => {}
    },
    chainWebpack: config => {
        config.module
            .rule('images')
            .use('url-loader')
            .loader('url-loader')
            .tap(options => {
                // 修改它的选项...
                options.limit = 100
                return options
            })
        if(process.env.NODE_ENV === "production") {
            config.plugin("extract-css").tap(() => [{
                path: path.join(__dirname, "./dist"),
                filename: "css/[name].[contenthash:8].css"
            }]);
        }
    },
    configureWebpack: config => {
        // vue骨架屏插件配置
        config.plugins.push(new SkeletonWebpackPlugin({
            webpackConfig: {
            entry: {
                app: path.join(__dirname, './src/pages/index/skeleton.js'),
            },
            },
            minimize: true,
            quiet: true,
        }))
        if(process.env.NODE_ENV === "production") {
            config.output = {
                publicPath: '/',
                path: path.join(__dirname, "./dist"),
                filename: "js/[name].[contenthash:8].js"            
            };
        }
    },
    // css相关配置
    css: {
        // 是否使用css分离插件 ExtractTextPlugin
        extract: true,
        // 开启 CSS source maps?
        sourceMap: false,
        // 启用 CSS modules for all css / pre-processor files.
        modules: false
    },
}





  • 写回答

1条回答 默认 最新

  • messilion 2023-04-26 16:29
    关注

    在Vue 3.0中配置多页面应用时,如果骨架配置无效,可能有以下几个原因:

    1. 骨架配置文件路径错误:在多页面应用中,每个页面都需要有自己的骨架配置文件。如果配置文件路径错误,那么该页面的骨架配置就会无效。要确保每个页面的骨架配置文件路径正确。

    2. 骨架配置文件中的 ID 错误:在骨架配置文件中,需要为每个页面指定一个唯一的 ID。如果多个页面的 ID 相同,那么其中一个页面的骨架配置就会被覆盖。要确保每个页面的 ID 不同,并且和对应的 HTML 文件中的 ID 相同。

    3. 骨架配置文件中的模板错误:在骨架配置文件中,模板需要和对应的 HTML 文件相匹配。如果模板错误,那么骨架配置就会无效。要确保每个页面的模板正确,并且和对应的 HTML 文件相匹配。

    4. Webpack 配置错误:在多页面应用中,需要对 Webpack 进行相应的配置。如果配置错误,那么骨架配置就会无效。要确保 Webpack 配置正确,并且能够正确地处理多个页面的骨架配置。

    评论

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块