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

fix: preprocess scss

上级 b5a4d9d9
......@@ -56,14 +56,14 @@ if (isSass) {
}
const scssLoader = {
loader: 'sass-loader',
loader: '@dcloudio/vue-cli-plugin-uni/packages/sass-loader',
options: {
sourceMap: false
}
}
const sassLoader = {
loader: 'sass-loader',
loader: '@dcloudio/vue-cli-plugin-uni/packages/sass-loader',
options: {
sourceMap: false
}
......
......@@ -38,6 +38,11 @@ const matchCss = /\.css$/i;
* @param {Function<string>} addNormalizedDependency
* @returns {Importer}
*/
const fs = require('fs')
const preprocessor = require('../../webpack-preprocess-loader/preprocess/lib/preprocess')
const {
cssPreprocessOptions
} = require('@dcloudio/uni-cli-shared')
function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
function dirContextFrom(fileContext) {
......@@ -51,6 +56,18 @@ function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
// Add the resolvedFilename as dependency. Although we're also using stats.includedFiles, this might come
// in handy when an error occurs. In this case, we don't get stats.includedFiles from node-sass.
addNormalizedDependency(resolvedFile);
const file = resolvedFile.replace(matchCss, '')
if (fs.existsSync(file)) {
const contents = fs.readFileSync(file, 'utf8')
if (contents.includes('#endif')) {
return {
file,
contents: preprocessor.preprocess(contents, cssPreprocessOptions.context, {
type: cssPreprocessOptions.type
})
}
}
}
return {
// By removing the CSS file extension, we trigger node-sass to include the CSS file instead of just linking it.
file: resolvedFile.replace(matchCss, '')
......@@ -72,4 +89,4 @@ function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
}
var _default = webpackImporter;
exports.default = _default;
\ No newline at end of file
exports.default = _default;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册