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

refactor(cli): devtool

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