Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Laravel Mix在Pug编译后缩小HTML_Html_Minify_Laravel Mix_Pug Loader - Fatal编程技术网

使用Laravel Mix在Pug编译后缩小HTML

使用Laravel Mix在Pug编译后缩小HTML,html,minify,laravel-mix,pug-loader,Html,Minify,Laravel Mix,Pug Loader,你能帮我在laravel mix pug之后的一行中使用html缩略代码吗 我的代码现在不起作用,我不知道原因是什么: let mix = require('laravel-mix'); mix.pug = require('laravel-mix-pug'); let pretty = true; if (mix.inProduction()) pretty = false; mix.js(['src/js/main.js', 'src/js/plugins.js'], 'dist/js/

你能帮我在laravel mix pug之后的一行中使用html缩略代码吗

我的代码现在不起作用,我不知道原因是什么:

let mix = require('laravel-mix');
mix.pug = require('laravel-mix-pug');

let pretty = true;
if (mix.inProduction()) pretty = false;

mix.js(['src/js/main.js', 'src/js/plugins.js'], 'dist/js/scripts.js')
    .sass('src/sass/app.scss', 'dist/css/styles.css')
    .options({
        processCssUrls: false
    })
    .pug('src/*.pug', '../dist', {
        pug: {
            pretty: pretty
        }
    });

mix.webpackConfig({
    module: {
        rules: [
            {
                test: /\.html$/,
                loader: 'html-loader',
                options: {
                    minimize: {
                        removeComments: true,
                        collapseWhitespace: true,
                        minifyJS: true
                    },
                },
            },
        ],
    },
});

只需安装html minifier并使用类似以下的laravel mix脚本编辑package.json:

“minify”:“html minifier--input dir./dist--output dir./dist--file ext html--collapse whitespace--remove comments--process conditional comments--minify js true”,
“产品”:“npm运行生产和npm运行缩小”

只需安装html minifier,并使用laravel mix脚本编辑package.json,如下所示:

“minify”:“html minifier--input dir./dist--output dir./dist--file ext html--collapse whitespace--remove comments--process conditional comments--minify js true”,
“产品”:“npm运行生产和npm运行缩小”