Skip to content

Commit

Permalink
Merge branch 'main' into feature/update-vue-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Dec 25, 2023
2 parents c346dca + e9198be commit f920101
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ module.exports = function (source, inMap) {
source,
filename: this.resourcePath,
id: `data-v-${query.id}`,
postcssPlugins: [...(() => {
const query = qs.parse(this.resourceQuery.slice(1));
const { id, scoped } = query;
if (!scoped) return [];
return [require('postcss-class-prefix')(`v${id}.`)];
})()],
map: inMap,
scoped: !!query.scoped,
scoped: false,
trim: true,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@ module.exports = function (source) {
// allow using custom compiler via options
const compiler = options.compiler || require('vue-template-compiler');

options.compilerOptions = {
modules: [{
postTransformNode: (el, options) => {
if (!options.scopeId) {
return;
}
const id = options.scopeId.replace('data-v-', 'v');
if (el.staticClass) {
el.staticClass = `"${id} ${el.staticClass.replace(/"/g, '')}"`;
} else {
el.staticClass = `"${id}"`;
}
},
}],
};

const compilerOptions = Object.assign({
outputSourceRange: true,
}, options.compilerOptions, {
scopeId: query.scoped ? `data-v-${id}` : null,
scopeId: query.scoped ? `v${id}` : null,
comments: query.comments,
});

Expand Down

0 comments on commit f920101

Please sign in to comment.