是否可以在网页包中加载SASS而不绑定字体,而是使用源地图?
我不想捆绑字体和图像,但我需要sourceMaps 我有这个配置(不相关的部分): 使用此配置,我在Chrome中遇到多个错误:是否可以在网页包中加载SASS而不绑定字体,而是使用源地图?,sass,webpack,Sass,Webpack,我不想捆绑字体和图像,但我需要sourceMaps 我有这个配置(不相关的部分): 使用此配置,我在Chrome中遇到多个错误: Failed to decode downloaded font: http://localhost:3000/ (index):1 OTS parsing error: invalid version tag 我读了很多关于类似问题的答案和解决方案: 1.摆脱“sourceMap”-它工作正常,字体显示正确,但。。。没有源地图 2.将publicPath更改为UR
Failed to decode downloaded font: http://localhost:3000/
(index):1 OTS parsing error: invalid version tag
我读了很多关于类似问题的答案和解决方案:
1.摆脱“sourceMap”-它工作正常,字体显示正确,但。。。没有源地图
2.将publicPath更改为URL-完成
我找不到任何解决方案,允许我在捆绑包外加载字体,并将CSS与sourceMaps一起使用…我刚刚找到了解决方案。解决方案的关键是ExtractTextPlugin,它使普通的链接标记而不是“blob”,所有字体都能超级工作,css是外部的(当它们很大时甚至更好),源地图也能工作。这是我的完整配置,如果有人感兴趣:
var path = require('path');
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
demo: ['./demo/index.ts', 'webpack-dev-server/client?http://localhost:3000'],
lib: ['./src/js/index.js']
},
output: {
path: './build/',
publicPath: '/',
filename: '[name].js'
},
debug: true,
devtool: 'source-map',
resolve: {
extensions: ['', '.ts', '.js']
},
module: {
loaders: [
{ test: /\.tsx?$/, loader: 'ts' },
{ test: /\.coffee$/, loader: 'coffee' },
{ test: /\.(png|jpg)$/, loader: 'url' },
{ test: /\.jsx?$/, loader: 'babel', query: { presets: ['es2015'] }, exclude: /node_modules/, },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?sourceMap!sass?sourceMap') },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css?sourceMap') },
{ test: /\.(ttf|eot|svg|woff(2)?)(\?[\s\S]+)?$/, loader: 'url' }
]
},
devServer: {
contentBase: './demo'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new ExtractTextPlugin("[name].css", { allChunks: true })
]
};
我刚想出来。解决方案的关键是ExtractTextPlugin,它使普通的链接标记而不是“blob”,所有字体都能超级工作,css是外部的(当它们很大时甚至更好),源地图也能工作。这是我的完整配置,如果有人感兴趣:
var path = require('path');
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
demo: ['./demo/index.ts', 'webpack-dev-server/client?http://localhost:3000'],
lib: ['./src/js/index.js']
},
output: {
path: './build/',
publicPath: '/',
filename: '[name].js'
},
debug: true,
devtool: 'source-map',
resolve: {
extensions: ['', '.ts', '.js']
},
module: {
loaders: [
{ test: /\.tsx?$/, loader: 'ts' },
{ test: /\.coffee$/, loader: 'coffee' },
{ test: /\.(png|jpg)$/, loader: 'url' },
{ test: /\.jsx?$/, loader: 'babel', query: { presets: ['es2015'] }, exclude: /node_modules/, },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?sourceMap!sass?sourceMap') },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css?sourceMap') },
{ test: /\.(ttf|eot|svg|woff(2)?)(\?[\s\S]+)?$/, loader: 'url' }
]
},
devServer: {
contentBase: './demo'
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new ExtractTextPlugin("[name].css", { allChunks: true })
]
};