i have a simple scss file
$fa-font-path: "~font-awesome/fonts";
$bootstrap-sass-asset-helper: false !default;
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
$icon-font-name: "glyphicons-halflings-regular" !default;
$icon-font-svg-id: "glyphicons_halflingsregular" !default;
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
@import '~font-awesome/scss/font-awesome';
*, *:before, *:after {
box-sizing: border-box;
}
html {
position: relative;
min-height: 100%;
}
body {
background-color: $bg;
margin-bottom: 60px;
}
And my webpack loader looks like this:
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff'
}
}
},
{
test: /\.(ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: 'file-loader'
},
{
test: /\.scss$/,
include: [
path.resolve(process.cwd(), "src/client/assets/styles"),
],
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
sourceMap: true,
modules: true,
importLoaders: 1,
localIdentName: '[local]_[hash:base64:3]'
}
},
{
loader: "postcss-loader",
options: postcssLoaderOptions
},
{
loader: "sass-loader",
options: {
sourceMap: true,
outputStyle: "compressed"
}
}
]
})
},
But i get errors when trying to include my scss
file
Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve '~font-awesome/fonts/fontawesome-webfont.eot?v=4.7.0'
Changing value for modules: true,
helps but i would like to keep it to true
ERROR in ./node_modules/css-loader?{"sourceMap":true,"modules":true,"importLoaders":1,"localIdentName":"[local]_[hash:base64:3]"}!./node_modules/postcss-loader/lib?{"plugins":[null],"sourceMap":true}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true,"outputStyle":"compressed"}!./src/client/assets/styles/styles.scss Module not found: Error: Can't resolve '~font-awesome/fonts/fontawesome-webfont.eot?v=4.7.0' in '/Users/vardius/Projects/webpack/src/client/assets/styles' @ ./node_modules/css-loader?{"sourceMap":true,"modules":true,"importLoaders":1,"localIdentName":"[local]_[hash:base64:3]"}!./node_modules/postcss-loader/lib?{"plugins":[null],"sourceMap":true}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true,"outputStyle":"compressed"}!./src/client/assets/styles/styles.scss 7:134621-134683
I had same issue and I found a solution for this errors.
First I removed the version numbers after the fonts files in the _path.scss in font-awesome scss folder.
src: url('#{$fa-font-path}/fontawesome-webfont.eot');
src: url('#{$fa-font-path}/fontawesome-webfont.eot') format('embedded-opentype'),
url('#{$fa-font-path}/fontawesome-webfont.woff2') format('woff2'),
url('#{$fa-font-path}/fontawesome-webfont.woff') format('woff'),
url('#{$fa-font-path}/fontawesome-webfont.ttf') format('truetype'),
url('#{$fa-font-path}/fontawesome-webfont.svg#fontawesomeregular') format('svg');
And then I added full folder path to $fa-font-path
variable
$fa-font-path : "./assets/vendor/font-awesome/fonts" !default;
Hopefully this solves your errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With