hoythan
V2EX  ›  Vue.js

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

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

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

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

    hoythan
        1
    hoythan  
    OP
       May 16, 2018
    已解决。
    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   ·   Solana   ·   1131 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 23:27 · PVG 07:27 · LAX 16:27 · JFK 19:27
    ♥ Do have faith in what you're doing.