var webpack = require(‘webpack‘); var HtmlWebpackPlugin = require(‘html-webpack-plugin‘); module.exports = { entry:{ ‘Greeter‘:__dirname + "/app/Greeter.js", ‘a‘:__dirname + "/app/a.js", ‘b‘:__dirname + "/app/b.js", ‘c‘:__dirname + "/app/c.js" }, output: { path: __dirname + "/build", filename: "[name]-[chunkhash].js" }, devServer:{ contentBase:"./public", historyApiFallback:true, inline:true }, module:{ loaders:[ { test:/\.json$/, loader:"json-loader" }, { test:/\.js$/, exclude:/node_modules/, loader:‘babel-loader‘ }, { test:/\.css$/, loader:‘style-loader!css-loader?modules‘ } ] }, plugins:[ new webpack.BannerPlugin("copyright suyan"), new HtmlWebpackPlugin({ template:__dirname + "/app/index.tmpl.html", title:‘htmlwebpackplugin filename test‘, filename:‘filename.html‘, inject:‘body‘, chunks:[‘a‘,‘c‘] }) ] }
cd app dir echo function a(){} > a.js dir more a.js echo function b(){} > b.js dir more b.js echo function c(){} > c.js
chunks的配置,为模板添加需要的a和c文件,那么这种情况b文件在filename中将不被引用
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1899449
原文地址:http://suyanzhu.blog.51cto.com/8050189/1899449