使用Webpack SCSS加载器将注释保存在.scss中

问题描述

使用此webpack配置加载scss文件,我试图将注释保留在开发模式下的scss文件中,并在生产模式下将其删除。

{
  test: /\.(scss|sass|css)$/,exclude: /node_modules/,use: [
    {
      loader: MiniCssExtractPlugin.loader,},{
      loader: 'css-loader',{
      loader: 'sass-loader',options: {
        sassOptions: {
          outputStyle: 'expanded',],

这是一个示例test.scss文件:

$block: ".test-";

#{$block} {
  // Comments
  &class {
    width: 100%;
    height: 100%;
  }
}

css的webpack输出为:

.test-class {
    width: 100%;
    height: 100%;
}

您可以看到我的评论消失了。但是,我想将注释保留在开发模式中,并在生产中将其删除。 我该如何实现?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...