webpack pack after running vue project and .woff not find .ttf file, or path error

 

webpack.base.config file, some people may be in utils.js

before fixing:

{
    test: /\.css$/,
    use: ExtractTextPlugin.extract({
    use: [‘css-loader?minimize‘, ‘autoprefixer-loader‘],
    fallback: ‘style-loader‘
    })
},
{
    test: /\.less$/,
    use: ExtractTextPlugin.extract({
    use: [‘css-loader?minimize‘,‘autoprefixer-loader‘, ‘less-loader‘],
    fallback: ‘style-loader‘
    }),
},

Modified:

{
    test: /\.css$/,
    use: ExtractTextPlugin.extract({
    use: [‘css-loader?minimize‘, ‘autoprefixer-loader‘],
    publicPath:‘../../‘,
    fallback: ‘style-loader‘
    })
},
{
    test: /\.less$/,
    use: ExtractTextPlugin.extract({
    use: [‘css-loader?minimize‘,‘autoprefixer-loader‘, ‘less-loader‘],
    publicPath:‘../../‘,
    fallback: ‘style-loader‘
    }),
},
{
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
}

Ttf file for ending / woff use url-loader loaded, to find the loader loads the style change package path.

Time is reloading css will change publicPath path is "../../", but also according to their custom directory structure. Such projects can be found after the packaged application corresponding to the path, so why change it, because we want to follow the path of the hierarchy after the pack to go, not according to the original project itself, there is little relative path sometimes can not find , why they wanted to change this absolute path, under static go looking times.

Guess you like

Origin blog.csdn.net/weixin_28898107/article/details/91418407