1 Star 0 Fork 364

manmade/魔方栈

forked from 华哲辰/魔方栈 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.js 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
华哲辰 提交于 2020-04-12 16:43 . try worker
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = () => ({
entry: {
index: "./src/index.ts",
},
output: {
path: path.resolve(__dirname, "./dist"),
publicPath: "./",
filename: "[name].[chunkhash].js",
globalObject: "this",
},
module: {
rules: [
{
test: /\.s(c|a)ss$/,
use: [
"vue-style-loader",
"css-loader",
{
loader: "sass-loader",
options: {
implementation: require("sass"),
fiber: require("fibers"),
},
options: {
implementation: require("sass"),
sassOptions: {
fiber: require("fibers"),
},
},
},
],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.tsx?$/,
loader: "ts-loader",
},
{
test: /\.(html|svg)?$/,
loader: "text-loader",
},
{
test: /.(png|woff(2)?|eot|ttf)(\?[a-z0-9=\.]+)?$/,
loader: "url-loader",
},
],
},
resolve: {
alias: {
vue$: "vue/dist/vue.esm.js",
},
extensions: ["*", ".js", ".ts", ".json"],
},
performance: {
hints: false,
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: "template.html",
filename: "index.html",
minify: {
removeComments: true,
collapseWhitespace: true,
minifyCSS: true,
},
}),
new WorkboxPlugin.GenerateSW({
// https://developers.google.cn/web/tools/workbox/reference-docs/latest/module-workbox-webpack-plugin.GenerateSW?hl=zh_cn#GenerateSW
clientsClaim: true,
skipWaiting: true,
cleanupOutdatedCaches: true,
directoryIndex: "./index.html",
exclude: [/./],
runtimeCaching: [
{
urlPattern: /cuber/,
handler: "NetworkFirst",
options: {
cacheName: "data",
matchOptions: {
ignoreSearch: true,
},
},
},
],
}),
new CopyWebpackPlugin([
{
from: __dirname + "/resource/",
to: __dirname + "/dist/",
ignore: ["*.html"],
},
]),
],
devtool: "",
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/490785184/cuber.git
git@gitee.com:490785184/cuber.git
490785184
cuber
魔方栈
master

搜索帮助