How to use the @dcloudio/uni-cli-shared.getPlatformScss function in @dcloudio/uni-cli-shared

To help you get started, we’ve selected a few @dcloudio/uni-cli-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dcloudio / uni-app / packages / vue-cli-plugin-hbuilderx / build / css-loader.conf.js View on Github external
const postcssLoader = {
  loader: 'postcss-loader',
  options: {
    sourceMap: false,
    parser: require('postcss-comment'),
    plugins: [
      require('postcss-import'),
      require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
    ]
  }
}

// sass 全局变量
const isSass = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'uni.sass'))
const isScss = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'uni.scss'))
let sassData = isSass ? getPlatformSass() : getPlatformScss()

if (isSass) {
  sassData = `@import "@/uni.sass"`
} else if (isScss) {
  sassData = `${sassData}
  @import "@/uni.scss";`
}

const scssLoader = {
  loader: 'sass-loader',
  options: {
    sourceMap: false
  }
}

const sassLoader = {
github dcloudio / uni-app / packages / vue-cli-plugin-uni / lib / options.js View on Github external
}
  if (!options.css.loaderOptions.postcss) {
    options.css.loaderOptions.postcss = {}
  }
  if (!options.css.loaderOptions.sass) {
    options.css.loaderOptions.sass = {}
  }

  if (!options.css.loaderOptions.postcss.config) {
    options.css.loaderOptions.postcss.config = {}
  }

  // sass 全局变量
  const isSass = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'uni.sass'))
  const isScss = fs.existsSync(path.resolve(process.env.UNI_INPUT_DIR, 'uni.scss'))
  let sassData = isSass ? getPlatformSass() : getPlatformScss()

  if (isSass) {
    sassData = `@import "@/uni.sass"`
  } else if (isScss) {
    sassData = `${sassData}
  @import "@/uni.scss";`
  }

  if (sassLoaderVersion < 8) {
    options.css.loaderOptions.sass.data = sassData
  } else {
    options.css.loaderOptions.sass.prependData = sassData
  }

  let userPostcssConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'postcss.config.js')
  if (fs.existsSync(userPostcssConfigPath)) {