提交 05625834 编写于 作者: fxy060608's avatar fxy060608

refactor(cli): devtool

上级 c924b047
......@@ -45,5 +45,10 @@ module.exports = {
},
'hybrid/html'
]
},
configureWebpack() {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'cheap-module-eval-source-map'
}
}
}
......@@ -40,5 +40,20 @@ module.exports = {
copyOptions.push(path.resolve(__dirname, '../template/v3'))
}
return copyOptions
},
configureWebpack (webpackConfig, vueOptions) {
let devtool = false
if (process.env.NODE_ENV !== 'production') {
if (process.env.UNI_USING_V3) {
if (vueOptions.pluginOptions['uni-app-plus']['service']) {
devtool = 'eval-source-map'
}
} else {
devtool = 'eval-source-map'
}
}
return {
devtool
}
}
}
......@@ -16,5 +16,10 @@ module.exports = {
},
copyWebpackOptions (platformOptions, vueOptions) {
return ['mycomponents']
},
configureWebpack () {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map'
}
}
}
......@@ -5,16 +5,21 @@ module.exports = {
'--window-top': '0px',
'--window-bottom': '0px'
},
extnames: {
style: '.css',
template: '.swan',
filter: '.filter.js'
extnames: {
style: '.css',
template: '.swan',
filter: '.filter.js'
},
filterTag: 'filter',
filterTag: 'filter',
project: 'project.swan.json',
subPackages: true
},
copyWebpackOptions (platformOptions, vueOptions) {
return ['swancomponents']
},
configureWebpack () {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'inline-source-map'
}
}
}
......@@ -37,5 +37,10 @@ module.exports = {
})
}
return copyOptions
},
configureWebpack () {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map'
}
}
}
......@@ -13,5 +13,10 @@ module.exports = {
},
copyWebpackOptions (platformOptions, vueOptions) {
return ['ttcomponents']
},
configureWebpack () {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'inline-source-map'
}
}
}
......@@ -37,5 +37,10 @@ module.exports = {
})
}
return copyOptions
},
configureWebpack () {
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map'
}
}
}
......@@ -64,10 +64,14 @@ module.exports = (api, options) => {
api.chainWebpack(require('./lib/chain-webpack')(platformOptions, options, api))
global.uniPlugin.configureWebpack.forEach(configureWebpack => {
api.configureWebpack(configureWebpack)
api.configureWebpack(function (webpackConfig) {
return configureWebpack(webpackConfig, options)
})
})
global.uniPlugin.chainWebpack.forEach(chainWebpack => {
api.chainWebpack(chainWebpack)
api.chainWebpack(function (webpackConfig) {
return chainWebpack(webpackConfig, options)
})
})
if (
......
......@@ -78,12 +78,6 @@ const v3 = {
webpackConfig.optimization.splitChunks = false
}
let devtool = false
if (isAppService && process.env.NODE_ENV !== 'production') {
devtool = 'eval-source-map'
}
const rules = []
const scriptLoaders = []
......@@ -126,7 +120,6 @@ const v3 = {
}
return {
devtool,
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
externals: {
vue: 'Vue'
......
......@@ -62,7 +62,6 @@ function getCopyWebpackPluginOptions (platformOptions, vueOptions) {
copyOption && copyOptions.push(copyOption)
})
})
console.log('debug:::', copyOptions)
return copyOptions
}
......
......@@ -17,7 +17,6 @@ process.env.UNI_INPUT_DIR = process.env.UNI_INPUT_DIR || path.resolve(process.cw
// 初始化全局插件对象
global.uniPlugin = require('@dcloudio/uni-cli-shared/lib/plugin').init()
console.log('debug:::', global.uniPlugin)
const manifestJsonObj = require('@dcloudio/uni-cli-shared/lib/manifest').getManifestJson()
const platformOptions = manifestJsonObj[process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM] || {}
// 插件校验环境
......
......@@ -102,7 +102,6 @@ module.exports = {
`import 'uni-pages';import 'uni-${process.env.UNI_PLATFORM}';`
return {
devtool: process.env.NODE_ENV === 'production' ? false : 'cheap-module-eval-source-map',
resolve: {
extensions: ['.nvue'],
alias: {
......
......@@ -77,29 +77,11 @@ module.exports = {
parseEntry()
let devtool = false
if (process.env.NODE_ENV !== 'production') {
if (process.env.UNI_PLATFORM === 'app-plus') {
if (process.env.UNI_USING_V8) {
devtool = 'eval-source-map'
} else {
devtool = 'eval'
}
} else if (
process.env.UNI_PLATFORM === 'mp-baidu' ||
process.env.UNI_PLATFORM === 'mp-toutiao'
) {
devtool = 'inline-source-map'
} else {
devtool = 'sourcemap'
}
}
const statCode = process.env.UNI_USING_STAT ? `import '@dcloudio/uni-stat';` : ''
const beforeCode = `import 'uni-pages';`
return {
devtool,
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry () {
return process.UNI_ENTRY
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册