0

I´m beggining with webpack to make a Wordpress theme. I would like to compile sass files to css files.

The goal is to compile style.sass to style.css without minify and keeping the standard comment header.

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({})
        ]
    }*/
};

style.sass

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

style.css

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

instead of...

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

How can I do this ?

J.BizMai
  • 2,621
  • 3
  • 25
  • 49

1 Answers1

0

The best way I found is to modify style.sass like this :

/*!
 Theme Name: My Theme
 Author: Robinson
 Author URI: https://robinson.org
J.BizMai
  • 2,621
  • 3
  • 25
  • 49