Permalink
Browse files

Adds `grunt-hello-world` example.

  • Loading branch information...
Paul Cuthbertson
Paul Cuthbertson committed Mar 27, 2016
0 parents commit 179c7e1ef1793c6256795906a5cd8c4c799d4440
@@ -0,0 +1,4 @@
+.DS_Store
+*/node_modules
+*/dist
+
@@ -0,0 +1,28 @@
+module.exports = function(grunt) {
+
+ grunt.initConfig({
+ starlight: {
+ hello: {
+ src: 'src/app.lua',
+ dest: 'dist/app.lua.js',
+ }
+ },
+
+ babel: {
+ options: {
+ plugins: ['transform-es2015-destructuring']
+ },
+ hello: {
+ src: 'dist/app.lua.js',
+ dest: 'dist/app.lua.js',
+ }
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-starlight');
+ grunt.loadNpmTasks('grunt-babel');
+
+ // Default task.
+ grunt.registerTask('default', ['starlight:hello', 'babel:hello']);
+
+};
@@ -0,0 +1,16 @@
+# grunt-hello-world
+
+A simple example that uses `grunt-starlight` to precompile a Lua script into JavaScript and use in a webpage.
+
+
+## Instructions.
+
+Navigate to the `grunt-hello-world` directory in a terminal, then install dependencies and run the build.
+This will compile `/src/app.lua` to `/dist/app.lua.js`.
+
+```
+npm install
+grunt
+```
+
+When the build is successful, view `/index.html` in your browser and you should see "Hello world!!" repeated in different colours.
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <script src="http://paulcuth.me.uk/starlight/browser-lib/starlight.js"></script>
+ <script src="dist/app.lua.js"></script>
+ </body>
+</html>
@@ -0,0 +1,27 @@
+{
+ "name": "grunt-starlight-hello-world",
+ "version": "1.0.0",
+ "description": "Working example of using `grunt-starlight`.",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/paulcuth/starlight-examples.git"
+ },
+ "keywords": [
+ "Lua",
+ "JavaScript",
+ "Grunt",
+ "examples"
+ ],
+ "author": "Paul Cuthbertson",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/paulcuth/starlight-examples/issues"
+ },
+ "homepage": "https://github.com/paulcuth/starlight-examples#readme",
+ "devDependencies": {
+ "babel-plugin-transform-es2015-destructuring": "^6.6.5",
+ "grunt-babel": "^6.0.0",
+ "grunt-cli": "^1.1.0",
+ "grunt-starlight": "^0.1.7"
+ }
+}
@@ -0,0 +1,18 @@
+window.extract()
+
+local colours = {
+ '#000000',
+ '#dd0000',
+ '#00dd00',
+ '#0000dd',
+ '#dddd00',
+ '#dd00dd',
+ '#dddddd',
+}
+
+for _, colour in ipairs(colours) do
+ local h1 = document:createElement('h1')
+ h1.textContent = 'Hello world!!'
+ h1.style.color = colour
+ document.body:appendChild(h1)
+end

0 comments on commit 179c7e1

Please sign in to comment.