cbl*_*bll 12 webpack webpack-2
我正在尝试为.png/.ttf加载添加查询,因为在升级到webpack 2之后,webpack会在编译时给出关于弃用的警告.
这是我的配置.如何正确添加照片和字体的查询?
const ExtractTextPlugin = require("extract-text-webpack-plugin");
var webpack = require("webpack");
module.exports = {
entry: {
dashboard: './js/main.js',
vendor: ["fixed-data-table","react","react-dom","jquery", "bootstrap", "vis"],
},
output: { path: "../public", filename: 'bundle.js' },
plugins: [
new webpack.optimize.CommonsChunkPlugin({name: "vendor", filename: "static/vendor.bundle.js"}),
new ExtractTextPlugin("/static/[name].css"),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
],
module: {
loaders: [
{
test: /.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
'es2015', 'react', 'stage-0',
],
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader'}),
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=~/.local/share/Trash/[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false', {
loader: 'image-webpack-loader',
},
],
query: {
gifsicle: {
interlaced: false,
},
optipng: {
optimizationLevel: 4,
},
pngquant: {
quality: '75-90',
speed: 3,
},
}
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=~/.local/share/Trash/[name].[ext]'
}
]
},
};
Run Code Online (Sandbox Code Playgroud)
reg*_*tar 32
我的webpack配置中有这个片段
{ test: /\.(ts|tsx)$/,
loader: ['ts-loader'],
options: { appendTsSuffixTo: [/\.vue$/] } },
Run Code Online (Sandbox Code Playgroud)
当我删除'ts-loader'周围的[]时,错误就消失了,例如
{ test: /\.(ts|tsx)$/,
loader: 'ts-loader',
options: { appendTsSuffixTo: [/\.vue$/] } },
Run Code Online (Sandbox Code Playgroud)
我认为消息是说你不能使用选项/查询多个加载器.它不能是一个数组,它必须是一个单独的加载器.
| 归档时间: |
|
| 查看次数: |
10663 次 |
| 最近记录: |