|
@@ -0,0 +1,68 @@
|
|
|
+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, '../dist'),
|
|
|
+ filename: '[name].[hash].js'
|
|
|
+ },
|
|
|
+ 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;
|