var path = require('path'); var htmlWebpackPlugin = require('html-webpack-plugin'); var webpack = require('webpack'); var AutodllWebpackpackPlugin = require('autodll-webpack-plugin'); var config = { entry: { index: ['babel-polyfill', './src/js/main.js'], login: ['babel-polyfill', './src/js/login.js'] }, output: { path: path.resolve(__dirname, '../broadcast'), filename: '[name].[hash].js', publicPath: '/' }, module:{ rules: [ { test: /\.js$/, include: path.join(__dirname,'..','src'), use: [ 'babel-loader' ], exclude: /node_modules/ }, { test: /\.(png|svg|jpg|gif)$/, use: [ { loader: "file-loader", options: { name: "[name].[ext]", publicPath: "./static/", outputPath: "static/" } } ] } ] }, plugins: [ new htmlWebpackPlugin({ filename: "login.html", title: "login", template: path.resolve(__dirname, '../src/login.html'), chunks: ['login'] }), new htmlWebpackPlugin({ filename: "index.html", title: "index", template: path.resolve(__dirname, '../src/index.html'), chunks: ['index'] }), new AutodllWebpackpackPlugin({ inject: true, debugger: true, filename: '[name].js', path: './dll', entry: { vendor: ['jquery'] } }), // 单独打包第三方库 new webpack.optimize.SplitChunksPlugin() //提取公共代码 ], resolve: { extensions: ['.js', '.css', '.less']// 省去后缀 } } module.exports = config;