V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hoythan
V2EX  ›  Vue.js

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

  •  
  •   hoythan · 2018-05-16 19:19:50 +08:00 · 3502 次点击
    这是一个创建于 2165 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

    hoythan
        1
    hoythan  
    OP
       2018-05-16 19:52:54 +08:00
    已解决。
    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]`)
    });
    }
    };
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   976 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:39 · PVG 03:39 · LAX 12:39 · JFK 15:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.