"use strict";

const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ScriptExtHtmlWebpackPlugin = require("script-ext-html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const {version} = require("../package.json");

const config = {
    entry: {
        main: path.join(__dirname, "../app/src/main"),
        db: path.join(__dirname, "../src/db"),
        setdex: path.join(__dirname, "../dist/setdex"),
        vendor: ["vue", "vue-i18n", "vue-multiselect"]
    },
    output: {
        filename: "[name].js",
        path: path.join(__dirname, "../dist/app")
    },
    stats: "minimal",
    resolve: {
        alias: {
            sulcalc: path.join(__dirname, "../src/sulcalc"),
            setdex: path.join(__dirname, "../dist/setdex"),
            translations: path.join(__dirname, "../dist/translations")
        }
    },
    module: {
        strictExportPresence: true,
        rules: [
            {
                test: /\.js$/,
                exclude: /(node_modules|db|translations|setdex)\//,
                loader: "babel-loader",
                options: {
                    babelrc: false,
                    plugins: [
                        "syntax-dynamic-import",
                        "transform-export-extensions",
                        "lodash"
                    ]
                }
            },
            {
                test: /\.hbs$/,
                loader: "handlebars-loader"
            },
            {
                test: /\.vue$/,
                loader: "vue-loader"
            },
            {
                test: /\.css$/,
                use: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: "css-loader"
                })
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            "process.libVersion": JSON.stringify(version)
        }),
        new ExtractTextPlugin("style.css"),
        new webpack.optimize.CommonsChunkPlugin({
            name: ["setdex", "db", "vendor"]
        }),
        new HtmlWebpackPlugin({
            template: path.join(__dirname, "../app/index.hbs"),
            hash: true,
            inject: "head"
        }),
        new ScriptExtHtmlWebpackPlugin({defaultAttribute: "defer"})
    ]
};

module.exports = config;

@@ -613,16 +613,28 @@
 %22%5Bname%5D.
+%5Bchunkhash%5D.
 js%22,%0A   
@@ -2045,16 +2045,30 @@
 (%22style.
+%5Bcontenthash%5D.
 css%22),%0A 
@@ -2273,32 +2273,8 @@
 %22),%0A
-            hash: true,%0A
     

Improve content caching