Conversation
Bootstrap and other resources should load assets from this URL path
|
Can you explain what this is for, and why it's necessary? |
|
When you build the Sass version of Bootstrap with webpack, without the publicPath, requests are sent to /somefile.woff, /somefile.ttf, etc. But the requests actually should be made to /assets/static/gen/somefile.woff. If you set publicPath to /static/gen/, URLs will be referenced properly. |
|
@bngsudheer I just tested this locally, and it doesn't seem to make any difference for where webpack outputs the font files. Your pull request also has a syntax error, since the |
|
Thanks for pointing out the missing comma. Fixed in 5df1f13 Some packages like bootstrap-sass needs to know the correct publicPath when generating the build. I will provide you examples of configs that fail without publicPath. |
|
Steps to reproduce the issue: Install bootstrap-sass and some required packages Webpack configuration to build Bootstrap: var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var options = {
entry: {
'app': './js/main.js',
'styles': './scss/main.scss',
'my.bootstrap.build': 'bootstrap-loader'
},
output: {
path: path.dirname(__dirname) + '/assets/static/gen',
filename: '[name].js'
},
devtool: '#cheap-module-source-map',
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js']
},
module: {
loaders: [
{
test: /bootstrap-sass\/assets\/javascripts\//,
loader: 'imports?jQuery=jquery'
},
{
test: /.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')
},
{
test: /.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
},
{
test: /.woff2?$|.ttf$|.eot$|.svg$|.png|.jpe?g|.gif$/,
loader: 'file'
}
]
},
plugins: [
new ExtractTextPlugin('styles.css', {
allChunks: true
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.DedupePlugin()
]
};
module.exports = options;Include the build in your template: Include some markup that uses Bootstrap fonts in your template: Now, you will see that request is being sent to If you look in the filesystem, the file 448c34a56d699c29117adc64c43affeb.woff2 is present in assets/static/gen/ If you provide proper publicPath the request will be sent to correct URL. |
|
Hi, I was having the same error, fonts, and images didn't generate correct paths. I noticed the problem trying to link font-awesome, and slick-carousel using sass |
75792c7 to
7b6c4b0
Compare
Bootstrap and other resources should load assets from this URL path