npm install coffee-script coffee-loader --save-dev
utils.js
var glob = require('glob');
exports.getEntries = function (globPath, extension) {
var entries = {}
glob.sync(globPath).forEach(function (entry) {
var tmp = new RegExp('\./src/([^\.]+)', 'g').exec(entry)[1]
if (extension) {
entries[tmp] = entry.replace(/\.\w+$/g, '.' + extension)
}
else {
entries[tmp] = entry
}
});
return entries;
}
webpack.dev.conf.js / webpack.prod.conf.js
var pages = utils.getEntries('./src/views/**/*.coffee', 'html')
for (var page in pages) {
var conf = {
filename: pages[page].substr(12),
template: pages[page],
inject: true,
excludeChunks: Object.keys(pages).filter(item => {
return (item != page)
})
}
module.exports.plugins.push(new HtmlWebpackPlugin(conf))
}
entry
entry: utils.getEntries('./src/views/**/*.coffee')
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。