小程序上线遇到了问题
小程序上线遇到了几个问题
1.npm run dev正常,npm run build报错,不知道有无影响
2.上传代码的时候有两个页面没有打包 不知道什么原因
3.我的项目发布,体验版本 手机拉去不到数据 ,我项目已经在阿里云发布,https://weapp.czmark.com
package.json代码
{
"name": "larabbs-weapp",
"version": "0.0.2",
"description": "larabbs weapp project",
"main": "dist/app.js",
"scripts": {
"dev": "wepy build --watch",
"build": "cross-env NODE_ENV=production wepy build --no-cache",
"dev:web": "wepy build --output web",
"clean": "find ./dist -maxdepth 1 -not -name 'project.config.json' -not -name 'dist' | xargs rm -rf",
"test": "echo \"Error: no test specified\" && exit 1",
"eslint": "eslint --fix --ext .js,.wpy src"
},
"wepy": {
"module-a": false,
"./src/components/list": "./src/components/wepy-list.wpy"
},
"author": "110733448@qq.com",
"license": "MIT",
"dependencies": {
"moment": "^2.24.0",
"promise-polyfill": "^8.1.0",
"redux": "^3.7.2",
"redux-actions": "^2.2.1",
"redux-promise": "^0.5.3",
"wepy": "^1.6.0",
"wepy-async-function": "^1.4.7",
"wepy-com-toast": "^1.0.2",
"wepy-plugin-imagemin": "^1.5.3",
"wepy-plugin-replace": "^1.5.10",
"wepy-redux": "^1.5.3"
},
"devDependencies": {
"babel-eslint": "^7.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.1.3",
"eslint": "^3.18.0",
"eslint-config-standard": "^7.1.0",
"eslint-friendly-formatter": "^2.0.7",
"eslint-plugin-html": "^2.0.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^2.0.1",
"less": "^3.8.1",
"wepy-compiler-babel": "^1.5.1",
"wepy-compiler-less": "^1.3.10",
"wepy-eslint": "^1.5.4"
}
}
app.js代码
import wepy from 'wepy'
//服务器接口地址
const host = __BASE_URL__
wepy.config.js代码
const path = require('path');
var prod = process.env.NODE_ENV === 'production';
module.exports = {
wpyExt: '.wpy',
eslint: true,
cliLogs: !prod,
build: {
web: {
htmlTemplate: path.join('src', 'index.template.html'),
htmlOutput: path.join('web', 'index.html'),
jsOutput: path.join('web', 'index.js')
}
},
resolve: {
alias: {
counter: path.join(__dirname, 'src/components/counter'),
'@': path.join(__dirname, 'src')
},
aliasFields: ['wepy', 'weapp'],
modules: ['node_modules']
},
compilers: {
less: {
compress: prod
},
/*sass: {
outputStyle: 'compressed'
},*/
babel: {
sourceMap: true,
presets: [
'env'
],
plugins: [
'transform-class-properties',
'transform-decorators-legacy',
'transform-object-rest-spread',
'transform-export-extensions',
]
}
},
plugins: {
replace: {
filter: /\.js$/,
config: {
find: /__BASE_URL__/g,
replace: prod ? "'https://weapp.czmark.com/api'" : "'http://larabbs.test/api'"
}
}
},
appConfig: {
noPromiseAPI: ['createSelectorQuery']
}
}
if (prod) {
// 压缩sass
// module.exports.compilers['sass'] = {outputStyle: 'compressed'}
// 压缩js
module.exports.plugins = {
uglifyjs: {
filter: /\.js$/,
config: {
}
},
imagemin: {
filter: /\.(jpg|png|jpeg)$/,
config: {
jpg: {
quality: 80
},
png: {
quality: 80
}
}
},
replace: {
filter: /\.js$/,
config: {
find: /__BASE_URL__/g,
replace: prod ? "'https://weapp.czmark.com/api'" : "'http://larabbs.test/api'"
}
}
}
}
请求帮助下,让我感受下成功的喜悦
推荐文章: