webpack url-loader使用时生成不了目标文件
相关代码
这个是webpack.config.js的代码
var webpack = require("webpack");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
//获取html-webpack-login模板的处理
var getHtmlConfig=function(name){
return {
filename: 'view/'+name+'.html',
template: './src/view/'+name+'.html',
inject: true,
hash:true,
chunks:['common',name]
}
}
var config = {
//是 页面入口文件配置 (html文件引入唯一的js 文件)
entry: {
'common': ["./src/page/common/index.js"],
"index": ["./src/page/index/index.js"],
"login": ["./src/page/login/index.js"]
},
//对应输出项配置
output: {
path: __dirname + "/dist",//输出文件的名称
filename: "js/[name].js",//入口文件最终要输ck哪里,
publicPath: './'
},
externals: {
"jquery": "window.jQuery"
},
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader","css-loader"),
},
{
test: /\.(woff|woff2|eot|ttf|svg|jpg|png)(\?[a-z0-9]+)?$/,
loader: 'url-loader?limit:10&name=resource/[name].[ext]&outputPath=img/'
},
]
},
plugins: [
//独立通用模块js/base.js
new webpack.optimize.CommonsChunkPlugin({
name: "common",
filename: "js/base.js"
}),
//把css单独打包到文件夹
new ExtractTextPlugin("css/[name].css"),
//html模板的处理
new HtmlWebpackPlugin(getHtmlConfig('index')),
new HtmlWebpackPlugin(getHtmlConfig('login'))
],
};
module.exports = config;
这个是css引入背景图
已解决,应该是版本的问题