webui-aria2/webpack.config.js
Pratik Borsadiya 1fccfd08bc Optimizations and fixes
- Remove vendor js libraries which are defined in package.json
- Fix some icon related issues in index-template.html
- Split javascript bundels in vendors and app
- Update prettier to fix scss source files and ignore build directory
2018-09-01 13:27:42 +05:30

64 lines
1.4 KiB
JavaScript

const path = require("path");
const webpack = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const BUILD_DIR = path.join(__dirname, "build");
const APP_DIR = path.join(__dirname, "src", "js");
const config = {
entry: {
app: APP_DIR + "/app.js"
},
module: {
rules: [
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader", "sass-loader"]
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "postcss-loader"]
}
]
},
output: {
path: BUILD_DIR,
filename: "[name].js"
},
plugins: [
new CleanWebpackPlugin(["build"]),
new webpack.ProvidePlugin({
"window.jQuery": "jquery",
jQuery: "jquery",
$: "jquery"
}),
new HtmlWebpackPlugin({
template: "src/index-template.html",
inject: "head"
}),
new MiniCssExtractPlugin({
filename: "[name].css"
})
],
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;