I'm using the vue-cli webpack template and I'm trying to load in local fonts in my project. I'm having trouble getting the path to my fonts correct. How should my path look like?
I found some information about what I might be doing wrong but I couldn't figure it out: https://github.com/webpack-contrib/sass-loader#problems-with-url
File structure:
In my _fonts.scss:
// Webfont: LatoLatin-Regular
@font-face {
font-family: 'LatoLatinWeb';
src: url('../assets/fonts/LatoLatin-Regular.eot'); /* IE9 Compat Modes */
src: url('../assets/fonts/LatoLatin-Regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('../assets/fonts/LatoLatin-Regular.woff2') format('woff2'), /* Modern Browsers */
url('../assets/fonts/LatoLatin-Regular.woff') format('woff'), /* Modern Browsers */
url('../assets/fonts/LatoLatin-Regular.ttf') format('truetype');
font-style: normal;
font-weight: normal;
text-rendering: optimizeLegibility;
}
Webpack.base.config.sj:
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
Utils.js:
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass').concat(
{
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../src/styles/_variables.scss')
}
}
).concat(
{
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../src/styles/mixins/_mixins.scss')
}
}
).concat(
{
loader: 'sass-resources-loader',
options: {
resources: path.resolve(__dirname, '../src/styles/_fonts.scss')
}
}
),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
How do I load my local fonts in with vue-cli webpack template?