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?
Requiring assets using the file-loader module is the way webpack is intended to be used (source). However, if you need greater flexibility or want a cleaner interface, you can also copy static files directly using my copy-webpack-plugin
(npm, Github). 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' }
]
})
]
};