From b404550b94ee098fa643aded8ea241e2c7d81a15 Mon Sep 17 00:00:00 2001 From: Nathan Reid Date: Sun, 5 Mar 2017 12:28:29 -0600 Subject: [PATCH 1/4] enable custom css modules compilers --- packages/vue-component/plugin/tag-handler.js | 63 +++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/packages/vue-component/plugin/tag-handler.js b/packages/vue-component/plugin/tag-handler.js index af2ac82..e6cc238 100644 --- a/packages/vue-component/plugin/tag-handler.js +++ b/packages/vue-component/plugin/tag-handler.js @@ -312,22 +312,53 @@ VueComponentTagHandler = class VueComponentTagHandler { // CSS Modules let isAsync = false; if (styleTag.attribs.module) { - const moduleName = typeof styleTag.attribs.module === 'string' ? styleTag.attribs.module : ''; - const scopedModuleName = moduleName ? `_${moduleName}` : ''; - plugins.push(postcssModules({ - getJSON(cssFilename, json) { - console.log('getjson') - cssModules = { ...(cssModules || {}), ...json }; - }, - generateScopedName(exportedName, filePath) { - const path = require('path'); - let sanitisedPath = path.relative(process.cwd(), filePath).replace(/.*\{}[/\\]/, '').replace(/.*\{.*?}/, 'packages').replace(/\.[^\.\/\\]+$/, '').replace(/[\W_]+/g, '_'); - const filename = path.basename(filePath).replace(/\.[^\.\/\\]+$/, '').replace(/[\W_]+/g, '_'); - sanitisedPath = sanitisedPath.replace(new RegExp(`_(${filename})$`), '__$1'); - return `_${sanitisedPath}__${exportedName}`; - }, - })); - isAsync = true; + if (global.vue.cssModules) { + try { + let compile = global.vue.cssModules; + //console.log(`Compiling ``` +### CSS Modules + +As an alternative to scoped styles, you can use CSS modules to scope your CSS to your components by adding the `module` attribute to any ` + + + + +``` + +Note: composing from other files is not supported by the built-in CSS modules processor. See the community packages. + +Community packages: + +- [nathantreid:vue-css-modules](https://github.com/nathantreid/vue-css-modules) enables interop with nathantreid:css-modules, including support for composing from other files. + + ### Language packages Using the power of preprocessors, you can use a different language (like less or jade) by adding a `lang` attribute on your `