1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Starting to add WebPack support.

This commit is contained in:
Gunther Brunner 2014-02-12 20:14:13 +09:00
parent 1fbaae8d8e
commit 7a0472abc9
7 changed files with 97 additions and 1 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
/doc/*.png /doc/*.png
/rethinkdb_data/ /rethinkdb_data/
/.env /.env
/tmp

39
Gruntfile.js Normal file
View file

@ -0,0 +1,39 @@
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt)
grunt.initConfig({
jade: {
translate: {
options: {
data: {
debug: false,
files: {
'tmp/html/all.html': ['views/**/*.jade']
}
}
}
}
},
nggettext_extract: {
pot: {
files: {
'lang/po/template.pot': ['tmp/html/all.html', 'public/js/controllers/**/*.js']
}
}
},
nggettext_compile: {
all: {
files: {
'public/js/lang/translations.js': ['lang/po/*.po']
}
}
}
})
grunt.registerTask('translate', ['jade:translate', 'nggettext_extract', 'nggettext_compile'])
grunt.registerTask('default', ['translate'])
}

View file

@ -445,6 +445,9 @@ program
, 'provider name (or os.hostname())' , 'provider name (or os.hostname())'
, String , String
, os.hostname()) , os.hostname())
.option('-w, --resources-watch'
, Boolean
, process.env.RESOURCES_WATCH)
.action(function() { .action(function() {
var log = logger.createLogger('cli') var log = logger.createLogger('cli')
, options = cliutil.lastArg(arguments) , options = cliutil.lastArg(arguments)

View file

@ -17,6 +17,9 @@ var wireutil = require('../wire/util')
var wirerouter = require('../wire/router') var wirerouter = require('../wire/router')
var dbapi = require('../db/api') var dbapi = require('../db/api')
var webpackMiddleware = require("webpack-dev-middleware")
var webpack = require("webpack")
var auth = require('../middleware/auth') var auth = require('../middleware/auth')
module.exports = function(options) { module.exports = function(options) {
@ -38,6 +41,34 @@ module.exports = function(options) {
app.use('/static/lib', express.static(pathutil.resource('lib'))) app.use('/static/lib', express.static(pathutil.resource('lib')))
app.use('/static', express.static(pathutil.resource('app'))) app.use('/static', express.static(pathutil.resource('app')))
// WebPack settings
app.use(webpackMiddleware(webpack( {
cache: true,
debug: true,
devtool: 'inline-source-map',
entry: pathutil.resource('app') + '/scripts/entry.js',
output: {
path: '/static/build/',
filename: 'bundle.js'
},
resolve: {
modulesDirectories: [pathutil.resource('lib'), './../../node_modules']
},
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.coffee$/, loader: 'coffee' }
]
}), {
noInfo: false,
quiet: false,
lazy: false,
publicPath: '/static/build/',
// public path to bind the middleware to use the same as in webpack
stats: {
colors: true
}
}))
app.use(express.cookieParser(options.secret)) app.use(express.cookieParser(options.secret))
app.use(express.cookieSession({ app.use(express.cookieSession({
key: options.ssid key: options.ssid

3
res/app/scripts/entry.js Normal file
View file

@ -0,0 +1,3 @@
//var angular = require('angular')
console.log('An entry')

View file

@ -2,6 +2,8 @@ doctype html
html html
head head
meta(charset='utf-8') meta(charset='utf-8')
title STF
body(ng-cloak) body(ng-cloak)
div(ng-view) div(ng-view)
script(src='/static/lib/requirejs/require.js', data-main='static/scripts/main.js') //script(src='/static/lib/requirejs/require.js', data-main='static/scripts/main.js')
script(src='/static/build/bundle.js')

17
webpack.config.js Normal file
View file

@ -0,0 +1,17 @@
module.exports = {
cache: true,
debug: true,
devtool: 'inline-source-map',
entry: './res/app/scripts/entry.js',
output: {
path: './res/app/build/',
filename: 'bundle.js'
},
resolve: {
modulesDirectories: ['./res/lib', 'node_modules']
},
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.coffee$/, loader: 'coffee' }
]
}