const webpack = require('webpack'); const path = require('path'); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const HtmlWebpackPlugin = require('html-webpack-plugin'); let theme = { '@primary-color': '#1DA57A', '@link-color': '#1DA57A', '@border-radius-base': '8px' }; module.exports = { entry: { 'user/index': ['webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port 'webpack/hot/only-dev-server', './js/user/index.js' ], 'user/login': ['webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port 'webpack/hot/only-dev-server', './js/user/login.js' ], 'admin/index': ['webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port 'webpack/hot/only-dev-server', './js/admin/index.js' ] //vendors: ['jquery','antd'] //path.resolve(__dirname, './js/index.js'), }, output: { path: path.resolve(__dirname, './build'), filename: '[name].js', }, module: { loaders: [{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', query: { "presets": ["es2015", "react"], "plugins": [ ["antd", { "style": true }] ] } //loaders: ['babel-loader?presets[]=es2015,presets[]=react'] }, //{ //test: /\.module\.less$/, //loader: 'style!css!less?{"modifyVars":{"@primary-color": "#1DA57A"}}' //}, { test: /\.css$/, loader: 'style!css' }, { test: /\.less$/, loader: `style!css!less?{"modifyVars":${JSON.stringify(theme)}}` }, { test: /\.(png|jpg)$/, loader: 'url?limit=8192&name=[path][name].[ext]' } //{test: /\.(png|jpg)$/, loader: 'file' } ] }, resolve: { extensions: ['', '.js', '.jsx'] }, plugins: [ new ExtractTextPlugin('[name].bundle.css', { allChunks: true }), //user new HtmlWebpackPlugin({ title: 'user_index', filename: 'user/index.html', template: './template/template.html', chunks:['user/index','vendors'] }), new HtmlWebpackPlugin({ title: 'user_login', filename: 'user/login.html', template: './template/template.html', chunks:['user/login','vendors'] }), //admin new HtmlWebpackPlugin({ title: 'admin_index', filename: 'admin/index.html', template: './template/template.html', chunks:['admin/index','vendors'] }) //这个使用uglifyJs压缩你的js代码 //new webpack.optimize.UglifyJsPlugin({minimize: true}), //把入口文件里面的数组打包成verdors.js //new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'), ] };