webpack 常用配置 自用
var htmlWebpackPlugin = require('html-webpack-plugin'); var CleanWebpackPlugin = require('clean-webpack-plugin'); var path = require("path"); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); module.exports = { entry:'./lib/main2.js', output:{ path: path.resolve(__dirname, '../lib'), filename:'[name].[hash].js' }, module:{ loaders:[ { test:/\.js$/, loader:'babel-loader', // exclude:'./node_modules/',//排除的范围 include:path.resolve(__dirname, '../lib/'),//包含的范围 // query:{ // presets:['lastest'] // } // 可以在package.json中加入 // "babel":{ // "presets":["lastest"] // }, }, { test:/\.css$/, loader:'style-loader!css-loader?importLoaders=1!postcss-loader' }, { test:/\.less$/, loader:'style-loader!css-loader?importLoaders=1!postcss-loader!less-loader' }, { test:/\.html$/, loader:'html-loader' }, { test:/\.tpl$/, loader:'ejs-loader' }, // { // test:/\.(png|jpg|gif|svg)$/i, // loader:'file-loader', // query:{ // name:'assets/[name].[ext]' // } // }, { test:/\.(png|jpg|gif|svg|woff|eot|ttf)$/i, loaders:[ 'url-loader?limite=20000&name=assets/[name].[ext]', 'image-webpack-loader'//压缩图片 ], // loader:'url-loader', // query:{ // limit:20000, // name:'assets/[name].[ext]' // } } ] }, plugins:[ new htmlWebpackPlugin({ filename:'../index.html', template:'index2.html', inject:'body' }), new UglifyJsPlugin(), new CleanWebpackPlugin( [ path.resolve('lib/main.*.js'), ], { root: path.resolve(__dirname, '../lib/'), verbose: true, dry: false, watch: true, } ), ] }
相关推荐
不知道该写啥QAQ 2020-11-12
webfullStack 2020-11-09
Yvettre 2020-09-15
想做大牛的蜗牛 2020-10-30
gloria0 2020-10-26
gaojie0 2020-09-11
SelinaChan 2020-08-14
不知道该写啥QAQ 2020-08-09
gloria0 2020-08-09
不知道该写啥QAQ 2020-08-02
hline 2020-07-29
SelinaChan 2020-07-28
wangdianyong 2020-07-23
webpackvuees 2020-07-23
yqoxygen 2020-07-20
不知道该写啥QAQ 2020-07-18
waterv 2020-07-18
81463166 2020-07-17