Authored by 徐炜

SPM改成webpack

... ... @@ -23,4 +23,4 @@ sea-modules
spm_modules
.cache
dist
web.log
web.log
\ No newline at end of file
... ...
... ... @@ -5,8 +5,8 @@ var fs = require('fs');
var exec = require('child_process').exec;
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
var ftpConfig = {
host: '218.94.75.58',
... ... @@ -18,7 +18,6 @@ gulp.task('default', function() {
});
//js代码验证
gulp.task('lint', function() {
return gulp.src(['src/*.js', 'src/**/*.js'])
... ... @@ -27,24 +26,20 @@ gulp.task('lint', function() {
});
//执行spm的build
gulp.task('spm', function(cb) {
exec('spm build --include standalone', function(err) {
if (err) return cb(err);
cb();
});
});
gulp.task('js', ['spm'], function() {
console.log("压缩合并完成");
});
//发布到CDN
gulp.task('dist', ['spm'], function() {
gulp.task('dist', ['build'], function() {
var ftpstream = ftp(ftpConfig);
return gulp.src('dist/**')
.pipe(ftpstream)
.pipe(gutil.noop());
});
gulp.task('build', function(done) {
webpack(webpackConfig, function(err, stats) {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack compile]:', stats.endTime - stats.startTime, 'ms');
done();
});
});
\ No newline at end of file
... ...
... ... @@ -2,7 +2,12 @@
"name": "yas-jssdk",
"version": "2.2.2",
"description": "YOHO!采集系统的前端js的开发包",
"keywords": ["YOHO!", "Acquisition", "System", "JS-SDK"],
"keywords": [
"YOHO!",
"Acquisition",
"System",
"JS-SDK"
],
"homepage": "",
"author": "hbomb <qiqi.zhou@yoho.cn>",
"repository": {
... ... @@ -29,15 +34,27 @@
"buildArgs": "--include standalone"
},
"devDependencies": {
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"babel-runtime": "^6.20.0",
"css-loader": "^0.26.1",
"expect.js": "^0.3.1",
"gulp": "^3.8.11",
"gulp-ftp": "^1.0.3",
"gulp-jshint": "^1.9.2",
"gulp-util": "^3.0.4",
"jshint-stylish": "^1.0.1",
"spm": "3"
"sinon": "^1.17.7",
"spm": "3",
"style-loader": "^0.13.1",
"webpack": "^1.14.0",
"webpack-uglify-parallel": "^0.1.3",
"yoho-json2": "^1.0.0"
},
"scripts": {
"test": "spm test",
"build": "spm build"
}
}
\ No newline at end of file
}
... ...
... ... @@ -2,7 +2,7 @@
* @fileoverview YAS (YOHO! Acquisition System) YOHO!采集系统的前端js的开发包,
* 用于在网页端采集信息(应用信息,用户信息,用户行为信息,浏览器及其系统信息)。
*/
require('yoho.json2');
require('yoho-json2');
//工具库
var util = require('./util');
... ... @@ -24,6 +24,7 @@ var version = config.version;
var yasPath = config.yaPath;
var yasDomain = config.yasDomain;
//应用信息
var appInfo = {
h: document.domain, //host
... ...
'use strict';
const webpack = require('webpack');
const path = require('path');
const _ = require('lodash');
const shelljs = require('shelljs');
const version = require('./package.json').version;
const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
const os = require('os');
module.exports = {
entry: {
'yas': './yas.js'
},
output: {
path: path.join('dist', 'yas-jssdk', version), // absolute path
filename: '[name].js'
},
module: {
loaders: [{
test: /\.css$/, loader: "style-loader!css-loader"
}],
resolve: {
modulesDirectories: ['node_modules']
}
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new UglifyJsParallelPlugin({
workers: os.cpus().length
})
]
};
... ...