How to copy static files to build directory with Webpack

0 votes

I'm trying to move from Gulp to Webpack. In Gulp I have task which copies all files and folders from /static/ folder to /build/ folder. How to do the same with Webpack? Do I need some plugin?

Sep 21, 2020 in Java-Script by kartik
• 37,520 points
7,147 views

1 answer to this question.

0 votes

Hello @kartik,

Requiring assets using the file-loader module is the way webpack is intended to be used. However, if you need greater flexibility or want a cleaner interface, you can also copy static files directly using my copy-webpack-plugin. For your static to build example:

const CopyWebpackPlugin = require('copy-webpack-plugin');
 
module.exports = {
    context: path.join(__dirname, 'your-app'),
    plugins: [
        new CopyWebpackPlugin({
            patterns: [
                { from: 'static' }
            ]
        })
    ]
};

Hope it helps!!
ThanK you!!

answered Sep 21, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to call jQuery UI Dialog with ASP.NET button postback?

Hello @kartik, To solve the problem with ASP:Button ...READ MORE

answered Apr 28, 2020 in Java-Script by Niroj
• 82,880 points
3,624 views
0 votes
1 answer

How to use React Router with Laravel?

Hii Kartik, Create a route that maps everything ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
6,750 views
+1 vote
2 answers

How to convert entire div data into image and save it into directory without using canvas?

Hello @kartik, You can try the sample code ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
72,766 views
0 votes
1 answer

How to get the directory of the currently running file?

Hello @kartik, This should do it: import ( ...READ MORE

answered May 6, 2020 in Java-Script by Niroj
• 82,880 points
1,369 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
22,960 views
0 votes
1 answer

What is type casting and type juggling in php?

Hey, The way by which PHP can assign ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
7,164 views
0 votes
2 answers

How can we create a session in PHP?

Hello, niroj. Here is my idea session_start(); $_SESSION['USERNAME'] ...READ MORE

answered Dec 7, 2020 in PHP by Famous
• 140 points
1,163 views
0 votes
1 answer

What is the use of $_REQUEST variable in php?

Hii @kartik, The $_REQUEST variable is used to read the ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,261 views
0 votes
1 answer

How can I send a message to a particular client with socket.io?

Hii, You can try the code below: io.to(socket.id).emit("event", data); whenever ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
27,809 views
0 votes
1 answer

How to set outerHTML with jQuery?

hello @kartik, This is innterHTML because it's inside ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
2,345 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP