123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- var path = require('path');
- var htmlWebpackPlugin = require('html-webpack-plugin');
- var webpack = require('webpack');
- var AutodllWebpackpackPlugin = require('autodll-webpack-plugin');
- var config = {
- entry: {
- index: path.resolve(__dirname, '../src/js/main.js'),
- login: path.resolve(__dirname, '../src/js/login.js')
- },
- output: {
- path: path.resolve(__dirname, '../broadcast'),
- filename: '[name].[hash].js',
- publicPath: '/'
- },
- module:{
- rules: [
- {
- test: /\.js$/,
- include: path.resolve(__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;
|