search

Home  >  Q&A  >  body text

javascript - Want to load a txt file using file-loader

Writing webpack.config.js like this seems invalid

  module:{
      loaders:[{
          test:/\.txt$/,
          loader:'file-loader'
      }]
  },

It’s been a long time and I’m almost crying

漂亮男人漂亮男人2837 days ago554

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:40:20

    Isn’t there an example on the official website of file-loader:

    In config

    { test: /\.html?$/, loader: 'file?name=html/[name].[ext]' },

    In the js entry file (flash.txt is now in the same directory as the entry js)

    require("file-loader?name=[hash]!./flash.txt");

    reply
    0
  • Cancelreply