UNPKG

mini-check

Version:

189 lines (183 loc) 4.71 kB
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: 'mini-check', date: '2020-05-05', designWidth: 750, deviceRatio: { '640': 2.34 / 2, '750': 1, '828': 1.81 / 2 }, sourceRoot: 'src', outputRoot: 'dist', babel: { sourceMap: true, presets: [ ['env', { modules: false }] ], plugins: [ 'transform-decorators-legacy', 'transform-class-properties', 'transform-object-rest-spread', ['transform-runtime', { "helpers": false, "polyfill": false, "regenerator": true, "moduleName": 'babel-runtime' }] ] }, defineConstants: { LOCATION_APIKEY: JSON.stringify('RDEBZ-F5O3I-AD5GA-5675L-ATUCQ-4VBC6') }, alias: { '@components': path.resolve(__dirname, '..', 'src/components'), '@styles': path.resolve(__dirname, '..', 'src/styles'), '@util': path.resolve(__dirname, '..', 'src/util'), '@assets': path.resolve(__dirname, '..', 'src/assets'), '@service': path.resolve(__dirname, '..', 'src/service'), }, copy: { patterns: [ ], options: { } }, mini: { webpackChain() { }, 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: true, // 默认为 false,如需使用 css modules 功能,则设为 true config: { namingPattern: 'module', // 转换模式,取值为 global/module generateScopedName: '[name]__[local]___[hash:base64:5]' } } } }, h5: { webpackChain() { }, devServer: { host: 'localhost', port: 10086, proxy: { '/reportService': { target: 'https://report-city-dev.abetatech.com', // 服务端地址 changeOrigin: true, }, '/bis': { target: 'https://report-city-dev.abetatech.com', // target: 'http://localhost:8283', changeOrigin: true, // pathRewrite: { '^/bis': '' }, }, '/tx/api/': { target: 'https://apis.map.qq.com/', changeOrigin: true, pathRewrite: { '^/tx/api': '/' }, } } }, esnextModules: ['taro-ui'], publicPath: '/', enableExtract: true, 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: true, // 默认为 false,如需使用 css modules 功能,则设为 true config: { namingPattern: 'module', // 转换模式,取值为 global/module generateScopedName: '[name]__[local]___[hash:base64:5]' } } } }, sassLoaderOption: { // importer: sassImportor }, } } if (process.env.TARO_BUILD_TYPE === 'ui') { Object.assign(config.h5, { enableSourceMap: false, enableExtract: false, enableDll: false }) config.h5.webpackChain = chain => { chain.plugins.delete('htmlWebpackPlugin') chain.plugins.delete('addAssetHtmlWebpackPlugin') chain.merge({ output: { path: path.join(process.cwd(), 'dist', 'h5'), filename: 'index.js', libraryTarget: 'umd', library: 'taro-ui-sample' }, externals: { nervjs: 'commonjs2 nervjs', classnames: 'commonjs2 classnames', '@tarojs/components': 'commonjs2 @tarojs/components', '@tarojs/taro-h5': 'commonjs2 @tarojs/taro-h5', 'weui': 'commonjs2 weui' } }) } } module.exports = function (merge) { if (process.env.NODE_ENV === 'development') { return merge({}, config, require('./dev')) } return merge({}, config, require('./prod')) }