Bootstrap-SASS Glyphicons 无法使用 Webpack 构建呈现
Bootstrap-SASS Glyphicons Not Rendering With Webpack Build
我正在使用 Webpack + NPM 构建我的应用程序,但在生产服务器上呈现 Bootstrap-SASS Glyphicons 时遇到了问题。本地 Glyphicons 渲染良好。
在Chrome中,我得到以下
Failed to decode downloaded font: http://app.azurewebsites.net/build448c34a56d699c29117adc64c43affeb.woff2
OTS parsing error: invalid version tag
Failed to decode downloaded font: http://app.azurewebsites.net/buildfa2772327f55d8198301fdb8bcfc8158.woff
OTS parsing error: invalid version tag
Failed to decode downloaded font: http://app.azurewebsites.net/builde18bbf611f2a2e43afc071aa2f4e1512.ttf
OTS parsing error: invalid version tag
下面是一些相关文件。我环顾四周,但未能找到解决方案。如果您有任何想法,请告诉我。谢谢
SCSS 文件
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';
@import '~bootstrap-sass/assets/stylesheets/_bootstrap.scss';
Webpack
var path = require('path');
var buildPath = "./build";
var webpack = require('webpack')
module.exports = {
entry: "./src/entry.js",
output: {
path: buildPath,
publicPath: buildPath,
filename: "bundle.js"
},
module: {
loaders: [
{test: /\.css$/, loader: 'style-loader!css'},
{test: /\.scss$/, loader: 'style-loader!css!sass'},
// { test: /.woff2?(\?v=\d+.\d+.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/, loader: 'url-loader?limit=8192'},
{test: /\.(eot|ttf)$/, loader: 'file-loader'}
]
}
};
NPM
"dependencies": {
"bootstrap-sass": "^3.3.6",
"node-sass": "^3.4.2",
"file-loader": "^0.8.5",
"css-loader": "^0.21.0",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.2"
}
找到解决办法。我通过执行以下操作为 path
指定绝对 url 来解决此问题:
output: {
path: path.resolve(__dirname, "build"),
publicPath: "build/",
filename: "bundle.js"
}
我正在使用 Webpack + NPM 构建我的应用程序,但在生产服务器上呈现 Bootstrap-SASS Glyphicons 时遇到了问题。本地 Glyphicons 渲染良好。
在Chrome中,我得到以下
Failed to decode downloaded font: http://app.azurewebsites.net/build448c34a56d699c29117adc64c43affeb.woff2
OTS parsing error: invalid version tag
Failed to decode downloaded font: http://app.azurewebsites.net/buildfa2772327f55d8198301fdb8bcfc8158.woff
OTS parsing error: invalid version tag
Failed to decode downloaded font: http://app.azurewebsites.net/builde18bbf611f2a2e43afc071aa2f4e1512.ttf
OTS parsing error: invalid version tag
下面是一些相关文件。我环顾四周,但未能找到解决方案。如果您有任何想法,请告诉我。谢谢
SCSS 文件
$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';
@import '~bootstrap-sass/assets/stylesheets/_bootstrap.scss';
Webpack
var path = require('path');
var buildPath = "./build";
var webpack = require('webpack')
module.exports = {
entry: "./src/entry.js",
output: {
path: buildPath,
publicPath: buildPath,
filename: "bundle.js"
},
module: {
loaders: [
{test: /\.css$/, loader: 'style-loader!css'},
{test: /\.scss$/, loader: 'style-loader!css!sass'},
// { test: /.woff2?(\?v=\d+.\d+.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/, loader: 'url-loader?limit=8192'},
{test: /\.(eot|ttf)$/, loader: 'file-loader'}
]
}
};
NPM
"dependencies": {
"bootstrap-sass": "^3.3.6",
"node-sass": "^3.4.2",
"file-loader": "^0.8.5",
"css-loader": "^0.21.0",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.2"
}
找到解决办法。我通过执行以下操作为 path
指定绝对 url 来解决此问题:
output: {
path: path.resolve(__dirname, "build"),
publicPath: "build/",
filename: "bundle.js"
}