postcss.config.js 874 B

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