T
T
tuxx2017-09-05 12:37:11
webpack
tuxx, 2017-09-05 12:37:11

How to copy files to folder before build starts in webpack?

The task is to build bootstrap 3 from less via webpack, but with a custom Superhero
Bootstrap theme I take from npm. The bootswatch.less and variabless.less files of the theme are in a different folder.
At first I googled the solution with copying the bootstrap.less file to my folder and changing the path for bootswatch.less and varialbes.less in it, but for some reason I don’t want to connect fontawesome fonts I
tried to use the copy-webpack-plugin plugin, but I I didn’t really understand what kind of strange manipulations with the paths are there. The maximum that was achieved is that in the debug mode the plugin writes that it sees the files, but does not copy them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tuxx, 2017-09-05
@tuxx

In general, I solved the problem myself, but a little crutch in my opinion. I made the copy-webpack-plugin plugin work, but in the settings I registered copying of each theme file individually, although it seems to be able to copy everything that is on the path to from using minimatch path templates.

plugins: [
    new CopyWebpackPlugin([
        {
          context: path.resolve(__dirname),
          from: './src/styles/bootstrap-theme/bootswatch.less',
          to: path.resolve(__dirname, './node_modules/bootstrap/less/bootswatch.less'),
        },
        {
          context: path.resolve(__dirname),
          from: './src/styles/bootstrap-theme/variables.less',
          to: path.resolve(__dirname, './node_modules/bootstrap/less/variables.less'),
        },
      ],
      {
        //debug: 'debug'
      })
  ]

While I was looking for a solution, I came across in the official documentation that webpack integrates perfectly into gulp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question