Commit 31d03871 by lirandong

merge develop

parents 1f9681b8 6d03ea4b
const path = require('path')
// NOTE 在 sass 中通过别名(@ 或 ~)引用需要指定路径
const lessImporter = function (url) {
if (url[0] === '~' && url[1] !== '/') {
return {
file: path.resolve(__dirname, '..', 'node_modules', url.substr(1))
}
}
const reg = /^@styles\/(.*)/
return {
file: reg.test(url) ? path.resolve(__dirname, '..', 'src/styles', url.match(reg)[1]) : url
}
}
const config = { const config = {
projectName: 'taroDemo', projectName: 'taroDemo',
date: '2019-8-12', date: '2019-8-12',
...@@ -11,11 +27,11 @@ const config = { ...@@ -11,11 +27,11 @@ const config = {
outputRoot: 'dist', outputRoot: 'dist',
alias: { alias: {
'@/': path.resolve(__dirname, '..', 'src'), '@/': path.resolve(__dirname, '..', 'src'),
'@api/': path.resolve(__dirname, '..', 'src/api'), '@/api': path.resolve(__dirname, '..', 'src/api'),
'@pages/': path.resolve(__dirname, '..', 'src/pages'), '@/pages': path.resolve(__dirname, '..', 'src/pages'),
'@actions/': path.resolve(__dirname, '..', 'src/actions'), '@/actions': path.resolve(__dirname, '..', 'src/actions'),
'@constants/': path.resolve(__dirname, '..', 'src/constants'), '@/constants': path.resolve(__dirname, '..', 'src/constants'),
'@conpoments/': path.resolve(__dirname, '..', 'src/conpoments'), '@/conpoments': path.resolve(__dirname, '..', 'src/conpoments'),
}, },
plugins: { plugins: {
babel: { babel: {
...@@ -30,6 +46,9 @@ const config = { ...@@ -30,6 +46,9 @@ const config = {
'transform-class-properties', 'transform-class-properties',
'transform-object-rest-spread' 'transform-object-rest-spread'
] ]
},
less: {
importer: lessImporter
} }
}, },
defineConstants: { defineConstants: {
...@@ -97,6 +116,9 @@ const config = { ...@@ -97,6 +116,9 @@ const config = {
generateScopedName: '[name]__[local]___[hash:base64:5]' generateScopedName: '[name]__[local]___[hash:base64:5]'
} }
} }
},
lessLoaderOption: {
importer: lessImporter
} }
} }
} }
......
...@@ -4,7 +4,7 @@ import Taro, { Component, Config } from '@tarojs/taro' ...@@ -4,7 +4,7 @@ import Taro, { Component, Config } from '@tarojs/taro'
import PageView from '@/constants/components/pageView' import PageView from '@/constants/components/pageView'
import { View, Text, Input, ScrollView, Image } from '@tarojs/components' import { View, Text, Input, ScrollView, Image } from '@tarojs/components'
import './less/index.less' import './less/index.less'
import api from '@/api' import api from '@/api/index'
import token from '@/constants/token' import token from '@/constants/token'
type PageStateProps = {} type PageStateProps = {}
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
"typeRoots": ["node_modules/@types"], "typeRoots": ["node_modules/@types"],
"paths": { "paths": {
"@/*": ["*"], "@/*": ["*"],
"@api/*": ["api/*"], "@/api*": ["api/*"],
"@pages/*": ["pages/*"], "@/pages*": ["pages/*"],
"@actions/*": ["actions/*"], "@/actions*": ["actions/*"],
"@constants/*": ["constants/*"], "@/constants*": ["constants/*"],
"@conpoments/*": ["conpoments/*"] "@/conpoments*": ["conpoments/*"]
} }
}, },
"exclude": ["node_modules", "dist"], "exclude": ["node_modules", "dist"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment