﻿const path = require("path");
const webpack = require("webpack");
const AssetsPlugin = require("assets-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");

const srcPath = path.resolve(__dirname, "./client/demo");
const distPath = path.resolve(__dirname, "./dist/public/assets");

module.exports = {
    context: srcPath,
    entry:
    {
        vendor: ["./common/vendor"],
        demo: ["./index"]
    },
    output:
    {
        path: distPath,
        publicPath: "/assets/",
        filename: "[name].js",
        chunkFilename: "[id].chunk.js"
    },
    resolve:
    {
        extensions: [".js", ".jsx"]
    },
    module:
    {
        rules:
        [
            {
                test: /\.jsx?$/,
                use:
                [
                    {
                        loader: "babel-loader",
                        options: { cacheDirectory: true }
                    }
                ],
                exclude: /node_modules/
            },
            {
                test: /\.(png|jpg)$/,
                use:
                [
                    {
                        loader: "url-loader",
                        options:
                        {
                            limit: 8192,
                            name: "res/[name].[ext]"
                        }
                    }
                ]
            },
            {
                test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                use:
                [
                    {
                        loader: "url-loader",
                        options:
                        {
                            limit: 8192,
                            mimetype: "application/font-woff",
                            name: "res/fonts/[name].[ext]"
                        }
                    }
                ]
            },
            {
                test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                use:
                [
                    {
                        loader: "file-loader",
                        options:
                        {
                            limit: 8192,
                            mimetype: "application/font-woff",
                            name: "res/fonts/[name].[ext]"
                        }
                    }
                ]
            }
        ]
    },
    plugins:
    [
        new CleanWebpackPlugin([distPath], { verbose: false }),
        new webpack.optimize.CommonsChunkPlugin({
            names: ["vendor", "manifest"],
            minChunks: Infinity
        }),
        new AssetsPlugin({
            filename: "assets.json",
            path: distPath,
            prettyPrint: true,
            includeManifest: "manifest"
        }),
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery"
        })
    ],
    stats:
    {
        children: false,
        maxModules: 0
    }
};

@@ -1,5 +1,4 @@
-%EF%BB%BF
 cons
@@ -2548,20 +2548,8 @@
 dor%22
-, %22manifest%22
 %5D,%0A 
@@ -2685,80 +2685,8 @@
 Path
-,%0A            prettyPrint: true,%0A            includeManifest: %22manifest%22
 %0A   

remove manifest