postcss.config.js 853 B

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