diff --git a/preset.json b/preset.json index 90f2f22..a4bf4fe 100644 --- a/preset.json +++ b/preset.json @@ -2,13 +2,13 @@ "useConfigFiles": false, "plugins": { "@dcloudio/vue-cli-plugin-uni": { - "version": "^2.0.1-32920211122002" + "version": "^2.0.1-alpha-35420220810001" }, "@dcloudio/vue-cli-plugin-uni-optimize": { - "version": "^2.0.1-32920211122002" + "version": "^2.0.1-alpha-35420220810001" }, "@dcloudio/vue-cli-plugin-hbuilderx": { - "version": "^2.0.1-32920211122002" + "version": "^2.0.1-alpha-35420220810001" }, "@vue/cli-plugin-babel": { "presets": [ diff --git a/template/common/babel.config.js b/template/common/babel.config.js index 48b7443..2b9ae2d 100644 --- a/template/common/babel.config.js +++ b/template/common/babel.config.js @@ -1,10 +1,11 @@ -const plugins = [] +const webpack = require('webpack') +const plugins = [] if (process.env.UNI_OPT_TREESHAKINGNG) { plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js')) -} +} -if ( +if ( ( process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8 @@ -12,7 +13,7 @@ if ( ( process.env.UNI_PLATFORM === 'h5' && process.env.UNI_H5_BROWSER === 'builtin' - ) + ) ) { const path = require('path') @@ -34,7 +35,7 @@ if ( } } ]) - } catch (e) {} + } catch (e) { } } process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'] @@ -55,7 +56,7 @@ const config = { [ '@vue/app', { - modules: 'commonjs', + modules: webpack.version[0] > 4 ? 'auto' : 'commonjs', useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry' } ] diff --git a/template/common/postcss.config.js b/template/common/postcss.config.js index db17d81..e149b58 100644 --- a/template/common/postcss.config.js +++ b/template/common/postcss.config.js @@ -1,7 +1,7 @@ -const path = require('path') -module.exports = { - parser: require('postcss-comment'), - plugins: [ +const path = require('path') +const webpack = require('webpack') +const config = { + plugins: [ require('postcss-import')({ resolve (id, basedir, importOptions) { if (id.startsWith('~@/')) { @@ -14,9 +14,13 @@ module.exports = { return id } }), - require('autoprefixer')({ + require('autoprefixer')({ remove: process.env.UNI_PLATFORM !== 'h5' }), require('@dcloudio/vue-cli-plugin-uni/packages/postcss') ] -} +} +if (webpack.version[0] <= 4) { + options.parser = require('postcss-comment') +} +module.exports = config