0

我开始使用 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({})
        ]
    }*/
};

风格.sass

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

样式.css

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

代替...

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

我怎样才能做到这一点 ?

4

1 回答 1

0

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

/*!
 Theme Name: My Theme
 Author: Robinson
 Author URI: https://robinson.org
于 2019-09-24T18:57:01.020 回答