0.2.3 • Published 5 years ago

postcss-assets-urls v0.2.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

postcss-assets-urls

PostCSS plugin for uploads local images to the CDN.

.foo {
  /* Input example */
   {
    background: url("/assets/opo9828c.jpg");
  }
}
.foo {
  /* Output example */
   {
    background: url("http://example.com/wp-content/themes78d01ea36bc481d6e154c691347243e5");
  }
}

Usage

postcss([
  require("postcss-assets-urls")({
    baseUrl: "http://cdn.io"
    // oss: {
    //   accessKeyId: 'accessKeyId',
    //   accessKeySecret: 'accessKeySecret',
    //   bucket: 'xmpt-sit',
    //   endpoint: 'https://oss-cn-shenzhen.aliyuncs.com',
    //   https: true,
    //   delDistImg: false,
    //   region: 'oss-cn-shenzhen'
    // }
  })
]);

Config with tarojs

weapp: {
    module: {
      postcss: {
        // "postcss-flexbugs-fixes": {
        //   enable: true
        // }
        autoprefixer: {
          enable: true
        },
        "postcss-assets-urls": {
          enable: true,
          config: {
            baseUrl: "https://bucket.oss-cn-shenzhen.aliyuncs.com",
            oss: {
              accessKeyId: "accessKeyId",
              accessKeySecret: "accessKeySecret",
              bucket: "bucket",
              endpoint: "https://oss-cn-shenzhen.aliyuncs.com",
              https: true,
              delDistImg: false,
              region: "oss-cn-shenzhen"
            }
          }
        }
      }
    }
  },