Source assets in webpack

Let's try source assets now. Let's make it so that the contents of text files go into a variable when imported:

webpack.config.jsexport default {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: path.resolve('dist'),
  },
  module: {
    rules: [
      {
        test: /\.txt$/,
        type: 'asset/source',
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin(),
  ],
};

Let's make a text file:

src/text.txtabcde

Let's connect this file to the entry point:

src/index.jsimport text from './text.txt';

The variable text will contain the contents of the text file:

src/index.jsconsole.log(text); // will bring out 'abcde'
Задание 1

Connect several text files to the entry point. Get their contents into variables.