简体   繁体   English

dist 文件夹子目录中的 Output fonts、css 文件和其他资产

[英]Output fonts, css files and other assets in a subdirectory of the dist folder

I'm following the guide on the official webpack website.我正在关注官方 webpack 网站上的指南。 For a reproducible code see this section in the official website.有关可重现的代码,请参阅官方网站中的 此部分

In the example provided, all the fonts are output under the dist folder.在提供的示例中,dist 文件夹下的所有 fonts 都是 output。 What I want is for the fonts to be output under a fonts subdirectory.我想要的是 fonts 是 fonts 子目录下的 output 。 Similarly for other types of assets such as css, images etc. I want them to be output under a folder depending on their extension.对于其他类型的资产(例如 css、图像等)也是如此。我希望它们是 output 在文件夹下,具体取决于它们的扩展名。

The output would look something like this: output 看起来像这样:

-/dist
--index.html
--bundle.js
--/css
---style1.css
--/fonts
---font1.woff
---font2.ttf

You can use file-loader to achieve that:您可以使用file-loader来实现:

  {
    test: /\.(png|svg|jpe?g|gif)$/,
    include: /images/,
    use: [
      {
        loader: 'file-loader',
        options: {
          name: '[name].[ext]',
          outputPath: 'images/',
          publicPath: 'images/'
        }
      }
    ]
  },
  {
    test: /\.(woff(2)?|ttf|otf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
    include: /fonts/,
    use: [
      {
        loader: 'file-loader',
        options: {
          name: '[name].[ext]',
          outputPath: 'fonts/',
          publicPath: 'fonts/'
        }
      }
    ]
  },

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有多种字体,js和css文件的Javascript Angular 4 Adding Assets文件夹 - Javascript Angular 4 Adding Assets folder with multiple fonts, js and css files 如何将CSS文件从源文件夹捆绑和复制到dist文件夹? - How to bundle and copy CSS files from source folder to dist folder? 只能生成js文件(位于dist文件夹中),而不能生成项目目录中的其他文件(如html,css ..)。 我正在使用“ build”:“ babel source -d dist” - Bable in only producing js files(in dist folder) and not other files in project directory(like html,css..). I am using “build”:“babel source -d dist” Ember构建输出(dist文件夹) - Ember build output (dist folder) CSS 和公用文件夹中的其他资产未包含在构建中 - CSS and other assets from the public folder not getting included in the build 从Android WebView中的Assets文件夹加载CSS和JS文件 - Load CSS and JS files from assets folder in android webview 如何将 google fonts 保留在 assets 文件夹中 - How to keep google fonts in assets folder 如何将“dist”文件夹转换为其源“src”和其他依赖文件夹和文件 - how to convert "dist" folder to its source "src" and other dependence folders and files 无法从dist文件夹中的webpack生成的index.html中引用javascript和css文件 - not able to reference javascript and css files from my index.html generated by webpack in dist folder webpack - 捆绑/复制所有要构建的资产或dist文件夹 - webpack - bundle / copy all assets to build or dist folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM