提交 5ffe6efc 编写于 作者: fxy060608's avatar fxy060608 提交者: qiang

fix(nvue): preprocess scss

上级 9b10a984
const uniI18n = require('@dcloudio/uni-cli-i18n')
function isPlainObject(a) {
function isPlainObject (a) {
if (a === null) {
return false
}
......@@ -8,7 +8,7 @@ function isPlainObject(a) {
}
module.exports = {
initCustomScript(name, pkgPath) {
initCustomScript (name, pkgPath) {
const pkg = require(pkgPath)
const uniAppOptions = pkg['uni-app']
......@@ -24,7 +24,9 @@ module.exports = {
}
if (!scriptOptions.env || !scriptOptions.env.UNI_PLATFORM) {
console.error(uniI18n.__('cliShared.requireConfigUniPlatform', { 0: `package.json->uni-app->scripts->${name}->env ` }))
console.error(uniI18n.__('cliShared.requireConfigUniPlatform', {
0: `package.json->uni-app->scripts->${name}->env `
}))
process.exit(0)
}
......@@ -32,7 +34,9 @@ module.exports = {
Object.keys(uniAppOptions.scripts).forEach(scriptName => {
if (scriptName !== name) {
const define = uniAppOptions.scripts[scriptName].define
Object.keys(define).forEach(name => define[name] = false)
Object.keys(define).forEach(name => {
define[name] = false
})
Object.assign(scriptOptions.define, define)
}
})
......@@ -46,4 +50,4 @@ module.exports = {
return scriptOptions
}
}
}
......@@ -58,6 +58,7 @@ if (isSass) {
const scssLoader = {
loader: '@dcloudio/vue-cli-plugin-uni/packages/sass-loader',
options: {
nvue: true,
sourceMap: false
}
}
......@@ -65,6 +66,7 @@ const scssLoader = {
const sassLoader = {
loader: '@dcloudio/vue-cli-plugin-uni/packages/sass-loader',
options: {
nvue: true,
sourceMap: false
}
}
......
......@@ -41,10 +41,11 @@ const matchCss = /\.css$/i;
const fs = require('fs')
const preprocessor = require('../../webpack-preprocess-loader/preprocess/lib/preprocess')
const {
cssPreprocessOptions
cssPreprocessOptions,
nvueCssPreprocessOptions
} = require('@dcloudio/uni-cli-shared')
function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
// fixed by xxxxxx
function webpackImporter(resourcePath, resolve, addNormalizedDependency, isNVue) {
function dirContextFrom(fileContext) {
return _path.default.dirname( // The first file is 'stdin' when we're using the data option
fileContext === 'stdin' ? resourcePath : fileContext);
......@@ -63,7 +64,7 @@ function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
if (contents.includes('#endif')) {
return {
file,
contents: preprocessor.preprocess(contents, cssPreprocessOptions.context, {
contents: preprocessor.preprocess(contents, isNVue ? nvueCssPreprocessOptions.context : cssPreprocessOptions.context, {
type: cssPreprocessOptions.type
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册