hoythan
V2EX  ›  Vue.js

Vue Cli 3.0 如何将 build 出来的文件整理到以前的 static 目录中?

  •  
  •   hoythan ·
    PRO
    · May 16, 2018 · 4189 views
    This topic created in 3105 days ago, the information mentioned may be changed or developed.

    项目从旧版的 cli 换到了 新版。配置好了以后发现 build 出来的项目代码全部散落在外面,不像之前的版本除了 index.html 外的文件都在 static 目录下,因为服务器要设置伪静态等规则,所以会导致无法使用以及根目录杂乱的问题。

    大家有配置过这个吗?应该如何修改

    hoythan
    hoythan
    OP
    PRO
    May 16, 2018
    1
    已解决。
    const path = require("path");
    module.exports = {
    lintOnSave: false,
    productionSourceMap: false,
    chainWebpack: chainableConfig => {
    const inlineLimit = 10000;
    const assetsPath = "static";
    chainableConfig.module
    .rule("images")
    .test(/\.(png|jpe?g|gif)(\?.*)?$/)
    .use("url-loader")
    .loader("url-loader")
    .options({
    limit: inlineLimit,
    name: path.join(assetsPath, `images/[name].[hash:8].[ext]`)
    });
    }
    };
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2474 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 04:59 · PVG 12:59 · LAX 20:59 · JFK 23:59
    ♥ Do have faith in what you're doing.