提交 ff6a0c47 编写于 作者: Q qiang

fix: remove sass-loader version check

上级 83c597e9
...@@ -8,10 +8,6 @@ const { ...@@ -8,10 +8,6 @@ const {
nvueCssPreprocessOptions nvueCssPreprocessOptions
} = require('@dcloudio/uni-cli-shared') } = require('@dcloudio/uni-cli-shared')
const {
sassLoaderVersion
} = require('@dcloudio/uni-cli-shared/lib/scss')
const nvueStyleLoader = { const nvueStyleLoader = {
loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style' loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style'
} }
...@@ -78,25 +74,15 @@ const sassLoader = { ...@@ -78,25 +74,15 @@ const sassLoader = {
} }
} }
if (sassLoaderVersion < 8) { scssLoader.options.prependData = sassData
scssLoader.options.data = sassData scssLoader.options.sassOptions = {
scssLoader.options.outputStyle = 'expanded' outputStyle: 'expanded'
}
sassLoader.options.data = sassData
sassLoader.options.outputStyle = 'expanded'
sassLoader.options.indentedSyntax = true
} else {
const name = sassLoaderVersion >= 9 ? 'additionalData' : 'prependData'
scssLoader.options[name] = sassData
scssLoader.options.sassOptions = {
outputStyle: 'expanded'
}
sassLoader.options[name] = sassData sassLoader.options.prependData = sassData
sassLoader.options.sassOptions = { sassLoader.options.sassOptions = {
outputStyle: 'expanded', outputStyle: 'expanded',
indentedSyntax: true indentedSyntax: true
}
} }
const lessLoader = { const lessLoader = {
......
const path = require('path') const path = require('path')
const webpack = require('webpack') const webpack = require('webpack')
const {
sassLoaderVersion
} = require('@dcloudio/uni-cli-shared/lib/scss')
const { const {
getPartialIdentifier getPartialIdentifier
} = require('./util') } = require('./util')
...@@ -112,21 +108,19 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) { ...@@ -112,21 +108,19 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
}) })
}) })
if (sassLoaderVersion >= 8) { // check indentedSyntax // vue cli 3 and sass-loader 8
// vue cli 3 and sass-loader 8 cssTypes.forEach(type => {
cssTypes.forEach(type => { webpackConfig.module.rule('sass').oneOf(type).use('sass-loader').tap(options => {
webpackConfig.module.rule('sass').oneOf(type).use('sass-loader').tap(options => { if (options.indentedSyntax) {
if (options.indentedSyntax) { if (!options.sassOptions) {
if (!options.sassOptions) { options.sassOptions = {}
options.sassOptions = {}
}
options.sassOptions.indentedSyntax = true
delete options.indentedSyntax
} }
return options options.sassOptions.indentedSyntax = true
}) delete options.indentedSyntax
}
return options
}) })
} })
platformOptions.chainWebpack(webpackConfig, vueOptions, api) platformOptions.chainWebpack(webpackConfig, vueOptions, api)
// define // define
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册