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:
parent
1fbaae8d8e
commit
7a0472abc9
7 changed files with 97 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
|||
/doc/*.png
|
||||
/rethinkdb_data/
|
||||
/.env
|
||||
/tmp
|
||||
|
|
39
Gruntfile.js
Normal file
39
Gruntfile.js
Normal 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'])
|
||||
}
|
|
@ -445,6 +445,9 @@ program
|
|||
, 'provider name (or os.hostname())'
|
||||
, String
|
||||
, os.hostname())
|
||||
.option('-w, --resources-watch'
|
||||
, Boolean
|
||||
, process.env.RESOURCES_WATCH)
|
||||
.action(function() {
|
||||
var log = logger.createLogger('cli')
|
||||
, options = cliutil.lastArg(arguments)
|
||||
|
|
|
@ -17,6 +17,9 @@ var wireutil = require('../wire/util')
|
|||
var wirerouter = require('../wire/router')
|
||||
var dbapi = require('../db/api')
|
||||
|
||||
var webpackMiddleware = require("webpack-dev-middleware")
|
||||
var webpack = require("webpack")
|
||||
|
||||
var auth = require('../middleware/auth')
|
||||
|
||||
module.exports = function(options) {
|
||||
|
@ -38,6 +41,34 @@ module.exports = function(options) {
|
|||
app.use('/static/lib', express.static(pathutil.resource('lib')))
|
||||
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.cookieSession({
|
||||
key: options.ssid
|
||||
|
|
3
res/app/scripts/entry.js
Normal file
3
res/app/scripts/entry.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
//var angular = require('angular')
|
||||
|
||||
console.log('An entry')
|
|
@ -2,6 +2,8 @@ doctype html
|
|||
html
|
||||
head
|
||||
meta(charset='utf-8')
|
||||
title STF
|
||||
body(ng-cloak)
|
||||
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
17
webpack.config.js
Normal 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' }
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue