webui-aria2/webpack.config.js

78 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-08-31 10:57:06 +02:00
const path = require("path");
const webpack = require("webpack");
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");
const WorkboxPlugin = require("workbox-webpack-plugin");
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 = {
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
}
]
},
output: {
path: BUILD_DIR,
filename: "[name].js"
},
plugins: [
new CleanWebpackPlugin(["docs"]),
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"
}),
new WorkboxPlugin.GenerateSW()
],
optimization: {
splitChunks: {
cacheGroups: {
commons: { test: /[\\/]node_modules[\\/]/, name: "vendor", chunks: "all" }
}
}
},
resolve: {
modules: [
path.resolve("./"),
path.resolve("./node_modules"),
path.resolve("./src/js"),
path.resolve("./src/scss")
]
}
};
module.exports = config;