Skip to content

Commit

Permalink
Add NodeJs development server
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikborsadiya committed May 27, 2018
1 parent 6b3c62d commit 244a880
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
node_modules/
dist/local.js
*/local.js
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ Vali is a free, modular and easy to customize admin theme built using [Bootstrap

Run a `npm install` command in project root directory to install and build dependencies. If you don't want to edit theme you can use the compiled files inside `docs` folder.

Use `npm run dev` task to watch and compile source files.
Use `npm run build` task to compile all source files.
Use `npm run dev` command to watch and compile source files.

## Customiztion
For more information about customizing theme colors please follow this [guide](http://pratikborsadiya.in/blog/vali-admin/).
Use `npm run build` command to compile all source files.

Use `npm run start` command to start a development server using NodeJs.

> **Note:**
> * The NodeJs server mentioned in `npm run start` command is for development purpose only. DONOT use it as a production server.
## Customization
For more information about customizing theme colors please follow the official [documentation](http://pratikborsadiya.in/blog/vali-admin/).

## RTL Support
Please follow this [guide](http://pratikborsadiya.in/blog/vali-admin/) to enable RTL support.
Please follow the official [documentation](http://pratikborsadiya.in/blog/vali-admin/) to enable RTL support.

## Contributors

* **[Pratik Borsadiya](http://pratikborsadiya.in)** - *Project Author*

See the list of [contributors](https://github.com/pratikborsadiya/vali-admin/graphs/contributors) who participated in this project.
List of [contributors](https://github.com/pratikborsadiya/vali-admin/graphs/contributors) who participated in this project.

## License

Expand Down
47 changes: 47 additions & 0 deletions node-dev-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Node JS development server for Vali Admin

var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;

http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname,
filename = path.join(process.cwd(), 'docs', uri);

var extname = path.extname(filename);
var contentType = 'text/html';

switch (extname) {
case '.js': contentType = 'text/javascript'; break;
case '.css': contentType = 'text/css'; break;
case '.ico': contentType = 'image/x-icon'; break;
case '.svg': contentType = 'image/svg+xml'; break;
}

fs.exists(filename, function(exists) {
if(!exists) {
response.writeHead(404, {"Content-Type": "text/plain"});
response.write("404 Not Found\n");
response.end();
return;
}

if (fs.statSync(filename).isDirectory()) filename += '/index.html';

fs.readFile(filename, "binary", function(err, file) {
if(err) {
response.writeHead(500, {"Content-Type": "text/plain"});
response.write(err + "\n");
response.end();
return;
}
response.writeHead(200, {'Content-Type': contentType});
response.write(file, "binary");
response.end();
});
});
}).listen(parseInt(port, 10));

console.log("Server is running on http://localhost:" + port );
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"scripts": {
"dev": "grunt watch",
"build": "grunt build"
"build": "grunt build",
"start": "node node-dev-server.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 244a880

Please sign in to comment.