var path=require('path');var webpack = require('webpack');var ExtractTextPlugin = require("extract-text-webpack-plugin");var HtmlWebpackPlugin = require('html-webpack-plugin');module.exports = { entry:{ vendor: ['react','react-dom','jquery','antd'], login:"./src/js/page/login.js", home:"./src/js/page/home.js" }, output:{ path: path.join(__dirname,'assets'), publicPath: "/assets/", //publicPath: "../", filename: "js/[name].js", chunkFilename: "js/[id].chunk.js" }, module: { loaders: [ //加载器 {test: /\.js$/, exclude:/node_modules/, loader:"react-hot!babel" }, {test: /\.jsx?$/, exclude:/node_modules/, loaders:["react-hot","babel"]}, {test: /\.(png|jpg)$/, loader: 'url-loader?name=img/[hash:8].[name].[ext]&limit=8192' }, {test: /\.css$/, loader:ExtractTextPlugin.extract("style", "css") } ] }, resolve:{ extensions:['','.js','.css','.jsx'] }, plugins:[ new webpack.optimize.CommonsChunkPlugin('vendor', 'js/vendor.bundle.js'), new webpack.optimize.CommonsChunkPlugin('antd/dist/antd.css', 'css/antd.css'), new webpack.ProvidePlugin({ $: 'jquery', React:'react', ReactDOM:'react-do', __ENV__:path.join(__dirname,"/env/"+ (process.env.NODE_ENV || "dev")) }), //new webpack.DefinePlugin({// definePlugin 接收字符串插入到代码当中, 所以你需要的话可以写上 JS 的字符串 // __ENV__: JSON.stringify(process.env.NODE_ENV || 'dev'), //}), new ExtractTextPlugin("css/[name].css") //单独使用style标签加载css并设置其路径 ]}