代码拉取完成,页面将自动刷新
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 WorkboxPlugin = require("workbox-webpack-plugin");
const BUILD_DIR = path.join(__dirname, "docs");
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"]
},
{
test: /\.svg$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "flags/"
}
}
]
}
]
},
output: {
path: BUILD_DIR,
filename: "[name].js"
},
plugins: [
new CleanWebpackPlugin(["docs"]),
new webpack.ProvidePlugin({
"window.jQuery": "jquery",
jQuery: "jquery",
$: "jquery"
}),
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;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。