/* 在webpack2.0版本已经将 module.loaders 改为 module.rules 为了兼容性考虑以前的声明方法任然可用,同时链式loader(用!连接)只适用于module.loader 同时-loader不可省略 */ rules: [{ test: /\.css$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: [{ loader: 'css-loader', options: { // modules: true // 设置css模块化,详情参考https://github.com/css-modules/css-modules } }, { loader: 'postcss-loader', // 在这里进行配置,也可以在postcss.config.js中进行配置,详情参考https://github.com/postcss/postcss-loader options: { plugins: function() { return [ require('autoprefixer')({browsers:['last 2 versions']}) ]; } } }] }), exclude: /node_modules/ //需要排除的目录 },{ test: /\.less?$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: [{ loader: 'css-loader', options: { // modules: true // 设置css模块化,详情参考https://github.com/css-modules/css-modules } }, { loader: 'postcss-loader', // 在这里进行配置,也可以在postcss.config.js中进行配置,详情参考https://github.com/postcss/postcss-loader options: { plugins: function() { return [ require('autoprefixer')({browsers:['last 2 versions']}) ]; } } },{ loader: "less-loader", options: { plugins: [ new CleanCSSPlugin({ advanced: true}) ] } }], publicPath: '../' }), },{ test: /\.(js|es6)$/, loader: 'babel-loader?presets[]=es2015', //此处不能用use },{ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, use: [{ //加载url-loader 同时安装 file-loader; loader : 'url-loader', options : { //小于10000K的图片文件转base64到css里,当然css文件体积更大; limit : 10000, //设置最终img路径; name : 'images/[name]-[hash:8].[ext]' } }] // loader:'file-loader?name=[name].[ext]&publicPath=./&outputPath=build/images/' // loader: 'url-loader', // query: { // limit: 10000, // name: 'images/[name].[hash:7].[ext]' // } },{ test: /\.(woff2?|woff|eot|ttf|otf)(\?.*)?$/, loader: 'url-loader', query: { limit: 10000, name:'fonts/[name].[hash:7].[ext]' } },{ test: /\.json$/, use: 'json-loader' },{ //https://github.com/pcardune/handlebars-loader/tree/master/examples test:/\.hbs$/, loader: "handlebars-loader" } `
|