postcss.config.js 936 B

12345678910111213141516171819202122232425262728293031323334
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const config = {
  4. parser: require('postcss-comment'),
  5. css: {
  6. loaderOptions: {
  7. less: {
  8. javascriptEnabled: true
  9. }
  10. }
  11. },
  12. plugins: [
  13. require('postcss-import')({
  14. resolve (id, basedir, importOptions) {
  15. if (id.startsWith('~@/')) {
  16. return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
  17. } else if (id.startsWith('@/')) {
  18. return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
  19. } else if (id.startsWith('/') && !id.startsWith('//')) {
  20. return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
  21. }
  22. return id
  23. }
  24. }),
  25. require('autoprefixer')({
  26. remove: process.env.UNI_PLATFORM !== 'h5'
  27. }),
  28. require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
  29. ]
  30. }
  31. if (webpack.version[0] > 4) {
  32. delete config.parser
  33. }
  34. module.exports = config