forked from styled-components/babel-plugin-styled-components
/
options.js
29 lines (24 loc) · 1.05 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pm from 'picomatch';
function getOption({ opts }, name, defaultValue = true) {
return opts[name] === undefined || opts[name] === null
? defaultValue
: opts[name]
}
export const useDisplayName = state => getOption(state, 'displayName')
export const useTopLevelImportPathMatchers = state =>
getOption(state, 'topLevelImportPaths', []).map(pattern => pm(pattern))
export const useSSR = state => getOption(state, 'ssr', true)
export const useFileName = state => getOption(state, 'fileName')
export const useMeaninglessFileNames = state => getOption(state, 'meaninglessFileNames', ['index'])
export const useMinify = state => getOption(state, 'minify')
export const useTranspileTemplateLiterals = state =>
getOption(state, 'transpileTemplateLiterals')
export const useNamespace = state => {
const namespace = getOption(state, 'namespace', '')
if (namespace) {
return `${namespace}__`
}
return ''
}
export const usePureAnnotation = state => getOption(state, 'pure', false)
export const useCssProp = state => getOption(state, 'cssProp', true)