Y
Y
yarovikov2021-09-16 12:52:55
webpack
yarovikov, 2021-09-16 12:52:55

How to overwrite an array in an object from the config?

Hi all. I use import config like this:

const defaultConfig = require('./node_modules/@wordpress/scripts/config/webpack.config.js');
const path = require('path');
const production = process.env.NODE_ENV === '';

module.exports = {
    ...defaultConfig,
    output: {
        path: path.resolve(__dirname, 'assets/build'),
        filename: '[name].js',
    },
    optimization: {
        ...defaultConfig.optimization,
    },
    module: {
        ...defaultConfig.module,
        rules: [
            ...defaultConfig.module.rules,
        ],
    },
    plugins: [...defaultConfig.plugins],
};


But I need to change this part in defaultConfig.module.rules

{
        test: /\.(woff|woff2|eot|ttf|otf)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'fonts/[name].[hash:8].[ext]',
            },
          },
        ],
      },


I’m not quite catching up on how to overwrite work with fonts in my config

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question