欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

webpack 将不同类型的文件输出到不同文件夹

程序员文章站 2024-02-10 13:00:04
...

参考:https://*.com/questions/33058964/configure-webpack-to-output-images-fonts-in-a-separate-subfolders

  module: {
    rules: [
      { 
        test: /\.less$/, 
        use: extractLESS.extract(["css-loader","less-loader"]),
      }, 
      {
        test: /\.(png|jpg|gif|jpeg)$/,
        loader: 'file-loader',
        options: {
          name: 'image/[name].[ext]?[hash]'
        }
      },
      {
        test: /\.(svg|woff|woff2|ttf|eot)$/,
        loader: 'file-loader',
        options: {
          name: 'font/[name].[ext]?[hash]'
        }
      },
    ]
  },
  output: {
    path: path.resolve('./dist'),
    publicPath: '/',
    filename: 'js/[name].[chunkhash].js'
  },