当我启动webpack
时,它会编译我的scss
文件并将小文件转换为base64
。但是,它也会将/img
文件夹中的大图像复制到输出文件夹中。我怎样才能防止webpack
这样做?我希望webpack
在图像文件夹中留下对原始图像的引用,而不是将它们复制到输出文件夹中。
webpack
创建的文件看起来像这样(在输出文件夹中):
5474fbe2d9c2987bc9345fb6cf66fd25.png
这是我的webpack配置文件:
module.exports = {
context: path.join(__dirname, "/www"),
entry: [
"./src/base/style.scss",
],
output: {
filename: "bundle.css",
path: path.join(__dirname, "/www/dist")
},
devtool: "source-map",
resolve: {
extensions: ["", ".scss"]
},
module: {
loaders: [
{
test: /.(scss|sass)$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader', 'sass-loader', 'postcss-loader', 'raw-loader'),
exclude: /node_modules/
},
{
test: /.(png|jpeg|jpg|gif|...)(?v=[0-9].[0-9].[0-9])?$/,
loader: 'url-loader?limit=2000'
}
],
preLoaders: [
{ test: /.(scss)$/, loader: "source-map-loader" }
]
},
postcss: function () {
return [autoprefixer, precss];
},
sassLoader: {
includePaths: [path.join(__dirname, 'www/src')]
},
plugins: [
new webpack.optimize.DedupePlugin(),
new ExtractTextPlugin('bundle.css')
]
}
set limit为1 and set name
{
test: /.(png|jpeg|jpg|gif|...)(?v=[0-9].[0-9].[0-9])?$/,
loader: 'url-loader',
query: {
limit: 1,
name: 'img/[name].[ext]?[hash:5]',
}
}