Answer the question
In order to leave comments, you need to log in
Why doesn't CopyWebpackPlugin copy images?
Hello everyone
Config:
const path = require("path");
const webpack = require("webpack");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const BUILD_DIR = path.resolve(__dirname, './dist');
module.exports = {
context: path.join(__dirname, '/'),
entry: ["babel-polyfill", "./src/index.js"],
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js"
},
devServer: {
contentBase: "./dist",
// outputPath: BUILD_DIR,
// hot: true,
historyApiFallback: true
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader"
}]
},
{
test: /\.css/,
use: ['style-loader', 'css-loader']
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
}
]
},
{test: /\.(jpe?g|gif|png|svg|woff|ttf|wav|mp3)$/, loader: "file"}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./public/index.html",
filename: "./index.html"
}),
new CopyWebpackPlugin([
{from: './src/img/*', to: './dist/img'}
], {})
]
};
let imgUrl = stories[key].img ? stories[key].img : "/img/no_image.jpg";
Answer the question
In order to leave comments, you need to log in
in addition to any overhead on the stack, I just copy folders with files
const CopyWebpackPlugin = require('copy-webpack-plugin');
// WriteFilePlugin needed only for webpack 3-4 and webpack dev-server
const WriteFilePlugin = require('write-file-webpack-plugin');
plugins: [
...
new WriteFilePlugin(),
new CopyWebpackPlugin([
{from: 'files', to: 'files'},
{from: 'images-2x', to: 'images-2x'},
{from: 'images', to: 'images'},
]),
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question