vue-loader
Advanced tools
Comparing version 16.3.3 to 16.4.0
@@ -11,2 +11,3 @@ import webpack = require('webpack'); | ||
refSugar?: boolean; | ||
customElement?: boolean | RegExp; | ||
hotReload?: boolean; | ||
@@ -13,0 +14,0 @@ exposeFilename?: boolean; |
@@ -49,2 +49,5 @@ "use strict"; | ||
}); | ||
const asCustomElement = typeof options.customElement === 'boolean' | ||
? options.customElement | ||
: (options.customElement || /\.ce\.vue$/).test(filename); | ||
// cache descriptor | ||
@@ -125,5 +128,9 @@ descriptorCache_1.setDescriptor(filename, descriptor); | ||
const idQuery = !style.src || style.scoped ? `&id=${id}` : ``; | ||
const query = `?vue&type=style&index=${i}${idQuery}${attrsQuery}${resourceQuery}`; | ||
const inlineQuery = asCustomElement ? `&inline` : ``; | ||
const query = `?vue&type=style&index=${i}${idQuery}${inlineQuery}${attrsQuery}${resourceQuery}`; | ||
const styleRequest = stringifyRequest(src + query); | ||
if (style.module) { | ||
if (asCustomElement) { | ||
loaderContext.emitError(`<style module> is not supported in custom element mode.`); | ||
} | ||
if (!hasCSSModules) { | ||
@@ -136,6 +143,14 @@ stylesCode += `\nconst cssModules = script.__cssModules = {}`; | ||
else { | ||
stylesCode += `\nimport ${styleRequest}`; | ||
if (asCustomElement) { | ||
stylesCode += `\nimport _style_${i} from ${styleRequest}`; | ||
} | ||
else { | ||
stylesCode += `\nimport ${styleRequest}`; | ||
} | ||
} | ||
// TODO SSR critical CSS collection | ||
}); | ||
if (asCustomElement) { | ||
stylesCode += `\nscript.styles = [${descriptor.styles.map((_, i) => `_style_${i}`)}]`; | ||
} | ||
} | ||
@@ -187,3 +202,6 @@ let code = [ | ||
// finalize | ||
code += `\n\nexport default script`; | ||
code += asCustomElement | ||
? `\n\nimport { defineCustomElement as __ce } from 'vue';` + | ||
`export default __ce(script)` | ||
: `\n\nexport default script`; | ||
return code; | ||
@@ -190,0 +208,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
const stylePostLoaderPath = require.resolve('./stylePostLoader'); | ||
const styleInlineLoaderPath = require.resolve('./styleInlineLoader'); | ||
const isESLintLoader = (l) => /(\/|\\|@)eslint-loader/.test(l.path); | ||
@@ -53,5 +54,9 @@ const isNullLoader = (l) => /(\/|\\|@)null-loader/.test(l.path); | ||
if (cssLoaderIndex > -1) { | ||
const afterLoaders = loaders.slice(0, cssLoaderIndex + 1); | ||
// if inlined, ignore any loaders after css-loader and replace w/ inline | ||
// loader | ||
const afterLoaders = query.inline != null | ||
? [styleInlineLoaderPath] | ||
: loaders.slice(0, cssLoaderIndex + 1); | ||
const beforeLoaders = loaders.slice(cssLoaderIndex + 1); | ||
return genProxyModule([...afterLoaders, stylePostLoaderPath, ...beforeLoaders], context, !!query.module); | ||
return genProxyModule([...afterLoaders, stylePostLoaderPath, ...beforeLoaders], context, !!query.module || query.inline != null); | ||
} | ||
@@ -58,0 +63,0 @@ } |
{ | ||
"name": "vue-loader", | ||
"version": "16.3.3", | ||
"version": "16.4.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Evan You", |
@@ -7,2 +7,9 @@ # vue-loader [![Build Status](https://circleci.com/gh/vuejs/vue-loader/tree/next.svg?style=shield)](https://circleci.com/gh/vuejs/vue-loader/tree/next) [![Windows Build status](https://ci.appveyor.com/api/projects/status/8cdonrkbg6m4k1tm/branch/next?svg=true)](https://ci.appveyor.com/project/yyx990803/vue-loader/branch/next) | ||
## v16 Only Options | ||
- `refSugar: boolean`: enable experimental ref sugar. | ||
- `customElement: boolean | RegExp`: enable custom elements mode. | ||
- Default is `/\.ce\.vue$/` | ||
- Setting to `true` will load all `.vue` files as native Custom Elements. | ||
## What is Vue Loader? | ||
@@ -9,0 +16,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67213
32
1081
125