个性化阅读
专注于IT技术分析

如何将style.sass编译为style.css并保持缩进

我正在与webpack开创一个Wordpress主题。我想将sass文件编译为css文件。

目标是将style.sass编译为style.css, 而无需最小化并保留标准注释标头。

webpack.config.js

const path = require('path');

// include the css extraction and minification plugins
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
//const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");

module.exports = {
    entry: './dev/my-theme/style.sass', output: {
        path: path.resolve(__dirname, 'dist/'), }, module: {
        rules: [
            // compile all .scss files to plain old css
            {
                test: /style.sass$/, use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
            }
        ]
    }, plugins: [
        // extract css into dedicated file
        new MiniCssExtractPlugin({
            filename: './my-theme/style.css'
        })
    ]/*, optimization: {
        minimizer: [
            // enable the css minification plugin
            new OptimizeCSSAssetsPlugin({})
        ]
    }*/
};

风格

/*!
/*! Theme Name: My Theme
/*! Author: Robinson
/*! Author URI: https://robinson.org
/*!

style.css

/*! *//*! Theme Name: My Theme *//*! Author: Robinson *//*! Author URI: https://robinson.org *//*! */

代替…

/*
Theme Name: My Theme
Author: Robinson
Author URI: https://robinson.org
*/ 

我怎样才能做到这一点 ?


#1


我发现的最好方法是像这样修改style.sass:

/*!
 Theme Name: My Theme
 Author: Robinson
 Author URI: https://robinson.org
赞(0)
未经允许不得转载:srcmini » 如何将style.sass编译为style.css并保持缩进

评论 抢沙发

评论前必须登录!