Comments (10)
I can take a look.
from webpack-boilerplate.
@nelsonvassalo Can you please explain what you're trying to do? I just tested background-image URLs in scss
files in folders, and it worked just fine on dev and build.
Generally, with SCSS you'll have index.scss
that imports everything else.
// index.scss
@import 'config/variables';
@import 'components/example';
Then from the folder, you'll refer to the URL based on the index
directory.
// components/_example.scss
.card {
background: url('../images/favicon.png');
}
You can test this right now and build
or start
and it'll work just fine. Please let me know or I'm closing this issue.
from webpack-boilerplate.
Hi,
It works fine yes, but the output urls are not relative to css file but to the root (starting with '/
'), which means if I host the sites elsewhere but the root they start failing. Was that clear?
from webpack-boilerplate.
@nelsonvassalo You mean if you host your website on https://www.example.com/subdirectory
vs https://www.example.com/
?
from webpack-boilerplate.
from webpack-boilerplate.
@nelsonvassalo Where are you putting your Webpack config relative to the directory? You should be able to put publicPath
:
output: {
path: paths.build,
publicPath: './subdirectory/'
filename: '[name].[contenthash].bundle.js',
},
from webpack-boilerplate.
I made an update, let me know if it fixes your issue. (You'll just need to update publicPath
from /
to /yourdirectory
.
from webpack-boilerplate.
Thanks!
It would still make them relative to root I think. To manage it's dependency free from root I've noticed you can pass a new publicPath option to MiniCSSExtract.loader
. Right now you0ve hardcoded ../../
. It seems this can be made actually relative by passing in the following function as value:
options: {
publicPath: (resourcePath, context) => {
// publicPath is the relative path of the resource to the context
// e.g. for ./css/admin/main.css the publicPath will be ../../
// while for ./css/main.css the publicPath will be ../
return path.relative(path.dirname(resourcePath), context) + '/';
}
}
…
}
from webpack-boilerplate.
Did you try it with the latest update? publicPath was removed from MiniCSSExtract.loader
and moved to output
in webpack.prod.js
. You should be able to put /yourdirectory
in publicPath
of ouput
. I don't 100% understand your setup and where you have your files located so I can't test it myself.
from webpack-boilerplate.
I'm going to close this issue, feel free to re-open if the issue persists.
from webpack-boilerplate.
Related Issues (20)
- very cool! can you add electron with this boilerplate?
- Adding Style Classes and IDs not working HOT 3
- Load fonts from public folder HOT 3
- Resolve alias not working HOT 1
- Several JS builds for each subpage HOT 1
- 2.0.1 scss=>css className And idName is hash HOT 1
- Cannot use SASS class selectors HOT 1
- how to load images from scss file HOT 1
- webpack-dev-server: "contentBase" was renamed to "static" HOT 1
- can't you make it as a template? HOT 2
- Production build can't find css/js files HOT 6
- Suggested node version
- ESLint suggestion
- Unused var in dev conf HOT 1
- changing index.html when running dev server seems doing nothing, the page only show the change after pressing refresh button . HOT 4
- SASS/SCSS not working
- Cannot apply update. Need to do a full reload! HOT 3
- 这个webpack搭建的脚手架
- 非常纯净的一款框架,项目可以根据这个基础框架进行调整,节约不少时间 HOT 2
- Pathing issue for prod build 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 webpack-boilerplate.