h5有缓存css,taro H5配置 cdn css js 缓存 hash 配置

1.taro使用详情请参考本https://nervjs.github.io/taro/docs搭建

2.关于文件的配置,在config/index.js添加相关配置

使得pages下面对应的文件夹可以使用对应的文件名而不是index.js,例如home.js

使得src下面的文件引用可以采用'@utils/jump'的引用方式(包括action,reducer,utils,styles等文件夹下的文件引用)

const path = require('path')

const sassImportor = function(url) {

const reg = /^@styles\/(.*)/

return {

file: reg.test(url) ? path.resolve(__dirname, '..', 'src/styles', url.match(reg)[1]) : url

}

}

const config = {

projectName: 'gant-taro',

date: '2019-2-26',

designWidth: 750,

deviceRatio: {

'640': 2.34 / 2,

'750': 1,

'828': 1.81 / 2

},

sourceRoot: 'src',

outputRoot: 'dist',

plugins: {

babel: {

sourceMap: true,

presets: [

['env', {

modules: false

}]

],

plugins: [

'transform-decorators-legacy',

'transform-class-properties',

'transform-object-rest-spread'

]

},

sass: {

importer: sassImportor

}

},

defineConstants: {

},

alias: {

'@actions': path.resolve(__dirname, '..', 'src/actions'),

'@assets': path.resolve(__dirname, '..', 'src/assets'),

'@components': path.resolve(__dirname, '..', 'src/components'),

'@constants': path.resolve(__dirname, '..', 'src/constants'),

'@reducers': path.resolve(__dirname, '..', 'src/reducers'),

'@styles': path.resolve(__dirname, '..', 'src/styles'),

'@utils': path.resolve(__dirname, '..', 'src/utils')

},

copy: {

patterns: [

],

options: {

}

},

weapp: {

module: {

postcss: {

autoprefixer: {

enable: true,

config: {

browsers: [

'last 3 versions',

'Android >= 4.1',

'ios >= 8'

]

}

},

pxtransform: {

enable: true,

config: {

}

},

url: {

enable: true,

config: {

limit: 10240 // 设定转换尺寸上限

}

},

cssModules: {

enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true

config: {

namingPattern: 'module', // 转换模式,取值为 global/module

generateScopedName: '[name]__[local]___[hash:base64:5]'

}

}

}

}

},

h5: {

publicPath: '/',

staticDirectory: 'static',

output: {

filename: 'js/[name].[hash].js',

chunkFilename: 'js/[name].[chunkhash].js'

},

imageUrlLoaderOption: {

limit: 5000,

name: 'static/images/[name].[hash].[ext]'

},

miniCssExtractPluginOption: {

filename: 'css/[name].[hash].css',

chunkFilename: 'css/[name].[chunkhash].css',

},

module: {

postcss: {

autoprefixer: {

enable: true,

config: {

browsers: [

'last 3 versions',

'Android >= 4.1',

'ios >= 8'

]

}

},

cssModules: {

enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true

config: {

namingPattern: 'module', // 转换模式,取值为 global/module

generateScopedName: '[name]__[local]___[hash:base64:5]'

}

}

}

},

sassLoaderOption: {

importer: sassImportor

}

}

}

module.exports = function (merge) {

if (process.env.NODE_ENV === 'development') {

return merge({}, config, require('./dev'))

}

return merge({}, config, require('./prod'))

}

3.由于antd只以h5和rn为端应用,taro面向的还有微信 支付宝 头条等等 ,所以说taro提供了taro-ui这个统一框架

详情请参考https://taro-ui.aotu.io/#/docs/introduction

作者:有风吹是幸福的

链接:https://www.jianshu.com/p/cbd78616c0a9

来源:简书

简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值