|
| 1 | +<<<<<<< HEAD |
| 2 | +const webpack = require('webpack') |
| 3 | +const plugins = [] |
| 4 | + |
| 5 | +if (process.env.UNI_OPT_TREESHAKINGNG) { |
| 6 | + plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js')) |
| 7 | +} |
| 8 | + |
| 9 | +if ( |
| 10 | + ( |
| 11 | + process.env.UNI_PLATFORM === 'app-plus' && |
| 12 | + process.env.UNI_USING_V8 |
| 13 | + ) || |
| 14 | + ( |
| 15 | + process.env.UNI_PLATFORM === 'h5' && |
| 16 | + process.env.UNI_H5_BROWSER === 'builtin' |
| 17 | + ) |
| 18 | +) { |
| 19 | + const path = require('path') |
| 20 | + |
| 21 | + const isWin = /^win/.test(process.platform) |
| 22 | + |
| 23 | + const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) |
| 24 | + |
| 25 | + const input = normalizePath(process.env.UNI_INPUT_DIR) |
| 26 | + try { |
| 27 | + plugins.push([ |
| 28 | + require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'), |
| 29 | + { |
| 30 | + file (file) { |
| 31 | + file = normalizePath(file) |
| 32 | + if (file.indexOf(input) === 0) { |
| 33 | + return path.relative(input, file) |
| 34 | + } |
| 35 | + return false |
| 36 | + } |
| 37 | + } |
| 38 | + ]) |
| 39 | + } catch (e) { } |
| 40 | +} |
| 41 | + |
| 42 | +process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'] |
| 43 | +process.UNI_LIBRARIES.forEach(libraryName => { |
| 44 | + plugins.push([ |
| 45 | + 'import', |
| 46 | + { |
| 47 | + 'libraryName': libraryName, |
| 48 | + 'customName': (name) => { |
| 49 | + return `${libraryName}/lib/${name}/${name}` |
| 50 | + } |
| 51 | + } |
| 52 | + ]) |
| 53 | +}) |
| 54 | + |
| 55 | +if (process.env.UNI_PLATFORM !== 'h5') { |
| 56 | + plugins.push('@babel/plugin-transform-runtime') |
| 57 | +} |
| 58 | + |
| 59 | +const config = { |
| 60 | + presets: [ |
| 61 | + [ |
| 62 | + '@vue/app', |
| 63 | + { |
| 64 | + modules: webpack.version[0] > 4 ? 'auto' : 'commonjs', |
| 65 | + useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry' |
| 66 | + } |
| 67 | + ] |
| 68 | + ], |
| 69 | + plugins |
| 70 | +} |
| 71 | + |
| 72 | +const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js' |
| 73 | +if (process.env.NODE_ENV === 'production') { |
| 74 | + config.overrides = [{ |
| 75 | + test: UNI_H5_TEST, |
| 76 | + compact: true, |
| 77 | + }] |
| 78 | +} else { |
| 79 | + config.ignore = [UNI_H5_TEST] |
| 80 | +} |
| 81 | + |
| 82 | +module.exports = config |
| 83 | +======= |
| 84 | +const webpack = require('webpack') |
| 85 | +const plugins = [] |
| 86 | + |
| 87 | +if (process.env.UNI_OPT_TREESHAKINGNG) { |
| 88 | + plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js')) |
| 89 | +} |
| 90 | + |
| 91 | +if ( |
| 92 | + ( |
| 93 | + process.env.UNI_PLATFORM === 'app-plus' && |
| 94 | + process.env.UNI_USING_V8 |
| 95 | + ) || |
| 96 | + ( |
| 97 | + process.env.UNI_PLATFORM === 'h5' && |
| 98 | + process.env.UNI_H5_BROWSER === 'builtin' |
| 99 | + ) |
| 100 | +) { |
| 101 | + const path = require('path') |
| 102 | + |
| 103 | + const isWin = /^win/.test(process.platform) |
| 104 | + |
| 105 | + const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) |
| 106 | + |
| 107 | + const input = normalizePath(process.env.UNI_INPUT_DIR) |
| 108 | + try { |
| 109 | + plugins.push([ |
| 110 | + require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'), |
| 111 | + { |
| 112 | + file (file) { |
| 113 | + file = normalizePath(file) |
| 114 | + if (file.indexOf(input) === 0) { |
| 115 | + return path.relative(input, file) |
| 116 | + } |
| 117 | + return false |
| 118 | + } |
| 119 | + } |
| 120 | + ]) |
| 121 | + } catch (e) { } |
| 122 | +} |
| 123 | + |
| 124 | +process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'] |
| 125 | +process.UNI_LIBRARIES.forEach(libraryName => { |
| 126 | + plugins.push([ |
| 127 | + 'import', |
| 128 | + { |
| 129 | + 'libraryName': libraryName, |
| 130 | + 'customName': (name) => { |
| 131 | + return `${libraryName}/lib/${name}/${name}` |
| 132 | + } |
| 133 | + } |
| 134 | + ]) |
| 135 | +}) |
| 136 | + |
| 137 | +if (process.env.UNI_PLATFORM !== 'h5') { |
| 138 | + plugins.push('@babel/plugin-transform-runtime') |
| 139 | +} |
| 140 | + |
| 141 | +const config = { |
| 142 | + presets: [ |
| 143 | + [ |
| 144 | + '@vue/app', |
| 145 | + { |
| 146 | + modules: webpack.version[0] > 4 ? 'auto' : 'commonjs', |
| 147 | + useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry' |
| 148 | + } |
| 149 | + ] |
| 150 | + ], |
| 151 | + plugins |
| 152 | +} |
| 153 | + |
| 154 | +const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js' |
| 155 | +if (process.env.NODE_ENV === 'production') { |
| 156 | + config.overrides = [{ |
| 157 | + test: UNI_H5_TEST, |
| 158 | + compact: true, |
| 159 | + }] |
| 160 | +} else { |
| 161 | + config.ignore = [UNI_H5_TEST] |
| 162 | +} |
| 163 | + |
| 164 | +module.exports = config |
| 165 | +>>>>>>> 210a1f252ad5cbfed5e05c854b2db97d7d42b800 |
0 commit comments