iamqiwei
V2EX  ›  问与答

scss 如何引入小程序 wxss 文件

  •  
  •   iamqiwei · Jun 7, 2021 · 1427 views
    This topic created in 1811 days ago, the information mentioned may be changed or developed.

    我在 scss 里面使用 @import 会报错,

    @import "xxxx.wxss";
    

    如果我把这个 wxss 文件改名为 css 就没问题= =
    有办法可以让 scss 正常引入 wxss 吗?
    或者忽略掉这个引入,直接输出 ‘@import "xxxx.wxss";’ 到 wxss 文件?
    我是 webstorm 的 file watcher 来处理的

    2 replies    2021-06-07 18:23:47 +08:00
    Ayers
        1
    Ayers  
       Jun 7, 2021
    我是使用 gulp 处理小程序的。关于 scss 里用 wxss 请参考。主要是利用 scss 的 screen 于正则替换
    ```
    // scss 文件
    @import '../xxx.wxss' screen;

    gulp
    ... // 省略
    .pipe(replace(/@import\s(.+)\sscreen;/g, function ($1, $2) {
    return '@import ' + $2 + ';';
    }))
    ... // 省略

    ```
    iamqiwei
        2
    iamqiwei  
    OP
       Jun 7, 2021
    @Ayers 好的,我研究一下
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2838 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 14:55 · PVG 22:55 · LAX 07:55 · JFK 10:55
    ♥ Do have faith in what you're doing.