用webpack打包的时候 入口文件可以定义多个,输出的时候 用output.path输出文件目录 [name]分别输出文件名,都打包在了一个目录里 我想输出的时候 输出在不同的目录里 用webpack如何去做呢 ?
认证高级PHP讲师
这样配: entry: { " dir1/dir2/dir3":'./index.jsx' }
var webpack = require("webpack"); module.exports = { entry: { file1: "./file1.js", file2: "./file2.js" }, output: { filename: "file1.bundle.js" }, plugins: [ new webpack.optimize.CommonsChunkPlugin("file2", "./anotherpath/file2.bundle.js") ] };
var getEntry = function(){
var entry = {}; glob.sync(__dirname+'/dev/**/*.js').forEach(function(name){ var n = name.slice(name.lastIndexOf('dev/')+4,name.length-3); entry[n] = name; }); return entry;
}
module.exports = {
entry:getEntry(), output:{ path:__dirname+'/public/', filename:'[name].js' }, module: { loaders: [ //{ test: /\.less$/, loader: 'style!css!less' }, // use ! to chain loaders { test: /\.less$/, loader: ExtractTextPlugin.extract("style-loader!css-loader","less-loader") }, { test: /\.(png|jpg)$/, loader: 'url?limit=8192'} ] }, resolve: { root:__dirname, extensions: ['', '.js', '.less'] }, plugins: [commonsPlugin,new ExtractTextPlugin("[name].less",{allChunks:true})]
var getEntry = function(){
}
module.exports = {
}