Comments (8)
Hey, I'm bringing this up again because I had the same issue, originated by a different cause.
I have a couple JPGs that are not referenced in the stylesheets and wanted to be copied to dist folder, because they're being used via JS.
I think every image from /images should be copied over to /dist/images. Is there a reason not to?
Thanks!
PS: Thanks again for a very interesting and useful project!
from static-site-boilerplate.
Ran into this problem as well, it's a Webpack thing. See https://stackoverflow.com/questions/48704770/webpack-is-not-copying-images-to-dist-folder which suggests the copy webpack plugin.
I implemented it into my project by editing the webpack.plugins.js
file and adding the code:
const CopyPlugin = require('copy-webpack-plugin');
const copyPlugin = new CopyPlugin([
{
from: 'images/**',
to: 'images/',
flatten: true
}
]);
And then adding the copyPlugin to the module.exports at the bottom:
config.env === 'production' && copyPlugin,
Now when I run the dist build, it copies all the images over too.
from static-site-boilerplate.
That's right, the path must be based on the src
directory structure. I've added this to the documentation.
Closing this for now, let me know if you have any further issues. Thanks!
from static-site-boilerplate.
Hey @tolchai, sorry I didn't clarify. The workaround I found is to link the file on my Sass, but never actually using that way on my frontend. Like so:
// This is to force the compilation into copying images to dist folder.
.dummy {
background-image: url("../images/bg-1.jpg");
background-image: url("../images/bg-2.jpg");
}
from static-site-boilerplate.
The problem is that in my scss file I have specified the path relative to the site, so the webpack just does not find the file. The path must be specified based on the directory structure namely
example:
src/
-images
-stylesheets
--styles.scss
in styles.scss path must be:
background: url("../images/pic1.jpeg");
from static-site-boilerplate.
Hey. I have a similar problem - can't figure out how to show image as inline background-image within style attribute. What is the right approach here? Thanks!
from static-site-boilerplate.
@iign Thanks! It's definitely not ideal, but it's working ) Also there is this problem with srcset #23. Best solution would be probably the one you have already mentioned here - just copy the whole content of /images folder to dist during build.
from static-site-boilerplate.
Yeah, I guess achieving that wouldn't be so difficult if one knows their way around webpack 🤔
from static-site-boilerplate.
Related Issues (20)
- Integrate file-include-webpack-plugin HOT 3
- Error: No configuration provided for styles.scss HOT 1
- Error "Option `sitemap` should be an absolute URL" when I run/build for production
- SSL Cert expired on docs page. HOT 1
- Video isn't being loaded during production. HOT 3
- Is there a way to implement permanent redirect?
- Cannot npm install on node 13.8.0
- HTML files in subfolders do not get styles / scripts. HOT 4
- Support for the experimental syntax 'optionalChaining' isn't currently enabled
- Fresh install npm install error HOT 6
- Use a templating/include engine HOT 1
- webp images are not being copied
- Images referenced in HTML are incorrectly deleted during production build HOT 4
- Unmodified clone doesn't build HOT 1
- devServer hot reload does not working. HOT 1
- When running NPM install site_url is blank and causes issues.
- FEAT: Use TailwindCSS for styling HOT 2
- Prebuilt libvips 8.10.5 binaries are not yet available for darwin-arm64v8 ( Apple M1 )
- Need to update node-sass to sass and update image-webpack-loader
- npm install fails HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from static-site-boilerplate.