2018-08-31 10:57:06 +02:00
|
|
|
const path = require("path");
|
|
|
|
const webpack = require("webpack");
|
2018-08-30 19:58:55 +02:00
|
|
|
|
2018-08-31 10:57:06 +02:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
|
|
const CleanWebpackPlugin = require("clean-webpack-plugin");
|
2018-09-05 08:17:00 +02:00
|
|
|
const WorkboxPlugin = require("workbox-webpack-plugin");
|
2018-08-30 19:58:55 +02:00
|
|
|
|
2018-09-07 15:58:23 +02:00
|
|
|
const BUILD_DIR = path.join(__dirname, "docs");
|
2018-08-31 10:57:06 +02:00
|
|
|
const APP_DIR = path.join(__dirname, "src", "js");
|
|
|
|
|
|
|
|
const config = {
|
2018-08-30 19:58:55 +02:00
|
|
|
entry: {
|
|
|
|
app: APP_DIR + "/app.js"
|
|
|
|
},
|
2018-08-31 10:57:06 +02:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader", "sass-loader"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"]
|
2018-09-02 07:42:49 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: "file-loader",
|
|
|
|
options: {
|
|
|
|
name: "[name].[ext]",
|
|
|
|
outputPath: "flags/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2018-08-31 10:57:06 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2018-08-30 19:58:55 +02:00
|
|
|
output: {
|
|
|
|
path: BUILD_DIR,
|
|
|
|
filename: "[name].js"
|
|
|
|
},
|
|
|
|
plugins: [
|
2018-09-07 15:58:23 +02:00
|
|
|
new CleanWebpackPlugin(["docs"]),
|
2018-08-30 19:58:55 +02:00
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
"window.jQuery": "jquery",
|
|
|
|
jQuery: "jquery",
|
|
|
|
$: "jquery"
|
2018-08-31 10:57:06 +02:00
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: "src/index-template.html",
|
|
|
|
inject: "head"
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name].css"
|
2018-09-06 15:50:52 +02:00
|
|
|
}),
|
|
|
|
new WorkboxPlugin.GenerateSW()
|
2018-08-30 19:58:55 +02:00
|
|
|
],
|
2018-09-01 09:57:42 +02:00
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
commons: { test: /[\\/]node_modules[\\/]/, name: "vendor", chunks: "all" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-08-30 19:58:55 +02:00
|
|
|
resolve: {
|
2018-09-01 09:57:42 +02:00
|
|
|
modules: [
|
|
|
|
path.resolve("./"),
|
|
|
|
path.resolve("./node_modules"),
|
|
|
|
path.resolve("./src/js"),
|
|
|
|
path.resolve("./src/scss")
|
|
|
|
]
|
2018-08-30 19:58:55 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = config;
|