diff --git a/template/common/postcss.config.js b/template/common/postcss.config.js index 53b23e3..28712ed 100644 --- a/template/common/postcss.config.js +++ b/template/common/postcss.config.js @@ -1,7 +1,18 @@ module.exports = { parser: require('postcss-comment'), plugins: [ - require('postcss-import'), + require('postcss-import')({ + resolve (id, basedir, importOptions) { + if (id.startsWith('~@/')) { + return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3)) + } else if (id.startsWith('@/')) { + return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2)) + } else if (id.startsWith('/') && !id.startsWith('//')) { + return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1)) + } + return id + } + }), require('autoprefixer')({ remove: process.env.UNI_PLATFORM !== 'h5' }),