Skip to content

Commit

Permalink
add build
Browse files Browse the repository at this point in the history
  • Loading branch information
kvkens committed May 29, 2017
1 parent 9bd4ec7 commit 46f8adb
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# uba-build
# uba build plugin

## 说明

构建`uba`项目打包产出静态资源功能

## 使用


```bash
uba build
```



## 更多

如果想挖掘更多的`uba`插件,请点击[Npmjs for uba-*](https://www.npmjs.com/search?q=uba-)
14 changes: 14 additions & 0 deletions bin/uba-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

var argv = require('minimist')(process.argv.slice(2));
var commands = argv._;


var opts = {
cmd: commands,
argv: argv,
name: "uba"
};


require("../src").plugin(opts);
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("./src");
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "uba-build",
"version": "0.0.1",
"description": "uba plugin for build",
"main": "index.js",
"bin": {
"uba-build": "./bin/uba-build.js"
},
"scripts": {
"test": "node test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/iuap-design/uba-build.git"
},
"keywords": [
"uba",
"build"
],
"author": "[email protected]",
"license": "MIT",
"bugs": {
"url": "https://github.com/iuap-design/uba-build/issues"
},
"homepage": "https://github.com/iuap-design/uba-build#readme",
"dependencies": {
"chalk": "^1.1.3",
"minimist": "^1.2.0",
"webpack": "^2.6.0",
"webpack-merge": "^4.1.0"
}
}
44 changes: 44 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var chalk = require("chalk");
var path = require("path");

var webpack = require("webpack");

function getHelp() {
console.log(chalk.green(" Usage : "));
console.log();
console.log(chalk.green(" uba build"));
console.log();
process.exit(0);
}

function getVersion() {
console.log(chalk.green(require("../package.json").version));
process.exit(0);
}

function build() {
var webpackConfig = require("./webpack.base");
webpack(webpackConfig, function(err, stats) {
if(!err){
console.log("uba build success!");
}else{
console.log(err);
}
});
}

module.exports = {
plugin: function(options) {
commands = options.cmd;
pluginname = options.name;
if (options.argv.h || options.argv.help) {
getHelp();
}
if (options.argv.v || options.argv.version) {
getVersion();
}

build();

}
}
34 changes: 34 additions & 0 deletions src/webpack.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var path = require("path");
var webpack = require("webpack");
var merge = require("webpack-merge");

var ubaConfig;



try {
ubaConfig = require(path.resolve(".","uba.config.js")).prodConfig;
} catch (e) {
console.log(e);
process.exit(0);
} finally {

}



var baseConfig= {
entry: {

},
output: {

},
module: {
rules: []
},
plugins: []
}


module.exports = merge(baseConfig, ubaConfig);
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var argv = require('minimist')(process.argv.slice(2));
var commands = argv._;


var opts = {
cmd: commands,
argv: argv,
name: "uba"
};

require("./").plugin(opts);

0 comments on commit 46f8adb

Please sign in to comment.