下面由laravel教程栏目给大家介绍laravel-mix 自动压缩html模板文件,希望对需要的朋友有所帮助!
laravel-mix 自动压缩html模板文件
laravel
cd /var/www/html/laravel-projectnpm i -D laravel-mix@^5.x laravel-mix-template-minifier watch shelljs
登录后复制
mix.minTemplate \= require("laravel-mix-template-minifier");mix.minTemplate("storage/framework/views/\*.php", "storage/framework/views/", { collapseInlineTagWhitespace: true, collapseWhitespace: true, minifyCSS: true, minifyJS: true, processConditionalComments: true, removeAttributeQuotes: false, removeComments: true, removeTagWhitespace: false, trimCustomFragments: false,});
登录后复制
let shell = require("shelljs");let watch = require("watch");let precessing = false;watch.watchTree("./storage/framework/views", function(f, curr, prev) { if (!precessing) { precessing = true; shell.exec("npm run prod"); setTimeout(() => { precessing = false; }, 5000); }});
登录后复制
nano /etc/rc.d/rc.local# 添加以下内容cd /var/www/html/ysmj-laravelnohup node compress.js > /var/www/html/laravel-project/compress.out 2>&1 &# 保存文件。然后设置权限使其开机自启chmod +x /etc/rc.d/rc.local
登录后复制
"scripts": { "dev": "npm run development", "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch-poll": "npm run watch -- --watch-poll", "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", "compress": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "prod": "npm run production", "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" },
登录后复制
let shell = require("shelljs");let watch = require("watch");let precessing = false;watch.watchTree("./storage/framework/views", function(f, curr, prev) { if (!precessing) { precessing = true; shell.exec("npm run compress"); setTimeout(() => { precessing = false; }, 5000); }});
登录后复制
以上就是laravel-mix怎么自动压缩html模板文件的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/3160254.html