I have this case, working fine on Mac... but when I cloned the repo on a Windows computer the build generates different results (paths) and it's not working.
All routes are relative to the build path:
fonts/abc.ttf
ttf file existing here
styles/styles.less
@font-face {
font-family: 'abc';
src: url(../fonts/abc.ttf);
}
examples/example.ts
import '../styles/styles.less';
webpack.config
{
test: /\.(css|scss|sass|less)$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'typings-for-css-modules-loader',
options: {
modules: true,
importLoaders: 1,
namedExport: true,
camelCase: true,
sourceMap: true,
localIdentName: '[local]',
},
},
{
loader: 'postcss-loader',
options: { plugins: () => [autoprefixer('ie >= 9')] },
},
],
}),
},
{
test: /\.(ttf|otf|eot|svg|woff(2)?)$/,
exclude: /node_modules/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
useRelativePath: true,
outputPath: 'fonts',
},
}],
},
In the mac environment, the output is correct:
fonts/abc.ttf
url(../fonts/abc.ttf)
In windows however:
fonts/fonts/abc.ttf
url(fonts/fonts/abc.ttf)
(giving that the css file is placed in /examples/example.css
the resulting url would be /examples/fonts/fonts/abc.ttf
so it's a 404So basically 2 questions:
fonts/fonts
)?..
to its path?And well, above all, why the results are not the same in win/mac?
The error was due to different versions being installed (1.1.6 vs 1.1.11) It might be that the latests introduce a bug, but installing the same version fixed the problem.
PS: Different versions was caused due to cleaning yarn.lock for different reasons.