用gulp如何给多个页面各自打包一个专属的js文件
发布网友
发布时间:2022-05-13 14:45
我来回答
共2个回答
热心网友
时间:2022-05-13 16:15
var webpack = require('webpack');var glob = require('glob');var debug = true;function getEntry() { var entry = {};
glob.sync(__dirname + "/app/js/*.main.js").forEach(function (file) { var name = file.match(/([^/]+?)\.main\.js/)[1];
entry[name] = __dirname + "/app/js/" + name + ".main.js";
}); return entry;
}//used while add min extfunction getExt() { return debug ? ".min.js" : "js";
}mole.exports = { // context: __dirname + "/app/",
entry: getEntry(), devtool: 'source-map', externals: { jquery: 'window.$'
}, output: { path: __dirname + '/build/js', filename: '[name].js',// + getExt(),
sourceMapFilename: '[file].map'
}, mole: { noParse: [], loaders: [{ test: /\.jsx?$/, loader: 'babel',
},
{ test:/\.less$/, loader:'style!css!less', options: { moles: true, localIdentName: '[path][name]__[local]--[hash:base64:5]'
}
}
]
}, debug: debug
};