B
B
bloster2019-05-15 18:53:31
webpack
bloster, 2019-05-15 18:53:31

Why is CopyWebpackPlugin transferring files not to the dist/ root?

Good afternoon, I'm setting up webpack, I need to transfer all php files from src to dist using CopyWebpackPlugin.
I have this code

const PATHS = {
  src: path.join(__dirname, "../src"),
  dist: path.join(__dirname, "../dist"),
  assets: "assets/"
};


new CopyWebpackPlugin([
      { from: `${PATHS.src}/img`, to: `${PATHS.assets}img` },
      { from: `${PATHS.src}/**/*.php`, to: `${PATHS.dist}` }
    ])

The plugin transfers all PHP files to dist, but not to the root, but creates a src folder inside dist and uploads all files there.
Where did I make a mistake? How can I make it so that everything is transferred to the dist root at once?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bloster, 2019-05-16
@bloster

Figured it out myself.
It was necessary to add a context line to the object, in the end it turned out like this

{
        from: `${PATHS.src}/**/*.php`,
        to: `${PATHS.dist}`,
        context: `${PATHS.src}/`
      },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question