npm run build后打开代码压缩上传,sync失效。压缩上传文件很小,打开速度很快,反之翻倍,这个问题如何处理。感谢!
如题
npm run builld
默认模板中,这一指令会压缩代码,因此不再需要再开启压缩上传
感谢回复,package配置为:"build": "cross-env NODE_ENV=production wepy build --no-cache",执行后,其中一个js为如下,不知是否算已经压缩过的: `'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _wepy = require('./../../npm/wepy/lib/wepy.js');
var _wepy2 = _interopRequireDefault(_wepy);
var _address_add_update = require('./../../mixins/address_add_update.js');
var _address_add_update2 = _interopRequireDefault(_address_add_update);
var _baseconfig = require('./../../mixins/baseconfig.js');
var _baseconfig2 = _interopRequireDefault(_baseconfig);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.proto = superClass; } /* eslint-disable key-spacing,keyword-spacing,semi-spacing,semi-spacing,no-redeclare,semi,quotes,indent */
var AddOrUpdateAddress = function (_wepy$page) { _inherits(AddOrUpdateAddress, _wepy$page);
function AddOrUpdateAddress() { var _ref;
var _temp, _this, _ret;
_classCallCheck(this, AddOrUpdateAddress);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = AddOrUpdateAddress.__proto__ || Object.getPrototypeOf(AddOrUpdateAddress)).call.apply(_ref, [this].concat(args))), _this), _this.mixins = [_address_add_update2.default, _baseconfig2.default], _this.config = {}, _this.components = {}, _this.data = {}, _this.methods = {}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(AddOrUpdateAddress, [{ key: 'onLoad', value: function onLoad(options) { var that = this; console.log({ that: that }); if (options.id === undefined || options.id === '' || options.id === null) { _wepy2.default.setNavigationBarTitle({ title: '新增收货地址' }); that.selProvince = '请选择'; that.selCity = '请选择'; that.mobile = ''; that.selDistrict = '请选择'; that.selProvinceID = ''; that.selCityID = ''; that.selDistrictID = ''; that.detailAddress = ''; that.name = ''; that.id = ''; } else { _wepy2.default.setNavigationBarTitle({ title: '修改收货地址' }); that.selProvince = options.province; that.selCity = options.city; that.mobile = options.mobile; that.selDistrict = options.district; that.selProvinceID = options.provinceId; that.selCityID = options.cityId; that.selDistrictID = options.districtId; that.detailAddress = options.simpleAddress; that.name = options.receiveName; that.id = options.id; } } }]);
return AddOrUpdateAddress; }(_wepy2.default.page);
Page(require('./../../npm/wepy/lib/wepy.js').default.$createPage(AddOrUpdateAddress , 'pages/address/add_or_update_address')); `
以上JS未被压缩。你是否改过wepy.config.js
查到问题了,执行npm run build 会提示压缩组件不存在,然后自动安装,安装后自动打包,但并未压缩。手动安装压缩组件后,恢复正常, 十分感谢!
@Gcaufy 同样遇到这个问题,执行npm run build 会提示 wepy-plugin-uglifyjs 等压缩插件不存在,然后又提示自动安装。但其实并未压缩,必须手动安装压缩插件,再重新 run build。
另外我是在 issues 里翻了半天才知道原来是执行npm run build 才会真正的压缩代码,文档里没有体现。
文档里缺少一些关于插件,编译器,wepy.config.js的一些配置相关的内容,新手的确不知道怎么上手。 @aben1188 看看这里是否能够帮忙补充完善一下呢?
@Gcaufy 我抽个时间发个 pull request 完善一下文档
@zaxlct https://github.com/wepyjs/wepy/tree/master/docs/md 感谢