Skip to content

Commit

Permalink
Initial draft
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Aug 7, 2016
1 parent 8f90893 commit 9eb6ee7
Show file tree
Hide file tree
Showing 53 changed files with 1,665 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"comments": false
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/*.js
config/*.js
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
env: {
browser: true
},
globals: {
'__THEME': true,
'cordova': true,
'$': true
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'brace-style': [2, 'stroustrup', { 'allowSingleLine': true }]
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
node_modules/
dist/
npm-debug.log
selenium-debug.log
test/unit/coverage
test/e2e/reports
cordova/platforms
cordova/plugins
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# quasar-play
App which helps develop Quasar Framework Apps http://quasar-framework.org
# Quasar Play

> App which helps develop Quasar Framework Apps http://quasar-framework.org
**Under development**
9 changes: 9 additions & 0 deletions build/hot-reload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')

hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})
6 changes: 6 additions & 0 deletions build/platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var theme = process.argv[2] || 'mat'

module.exports = {
theme: theme,
cordovaAssets: './cordova/platforms/' + (theme === 'mat' ? 'android' : 'ios') + '/platform_www'
}
30 changes: 30 additions & 0 deletions build/script.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

var
shell = require('shelljs'),
path = require('path'),
config = require('../config'),
platform = require('./platform'),
webpack = require('webpack'),
webpackConfig = require('./webpack.prod.conf'),
targetPath = path.join(__dirname, '../dist')

process.env.NODE_ENV = 'production'
console.log(' Built files are meant to be served over an HTTP server.')
console.log(' Opening index.html over file:// won\'t work.\n')

require('./script.clean.js')
console.log(' Building Quasar App with "' + platform.theme + '" theme...')

shell.mkdir('-p', targetPath)
shell.cp('-R', 'src/statics', targetPath)

webpack(webpackConfig, function (err, stats) {
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n')
})
7 changes: 7 additions & 0 deletions build/script.clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var
shell = require('shelljs')
,path = require('path')
,config = require('../config')

shell.rm('-rf', path.resolve(__dirname, '../dist'))
console.log(' Cleaned build artifacts.\n')
72 changes: 72 additions & 0 deletions build/script.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
var
path = require('path'),
express = require('express'),
webpack = require('webpack'),
config = require('../config'),
platform = require('./platform'),
proxyMiddleware = require('http-proxy-middleware'),
webpackConfig = process.env.NODE_ENV === 'testing'
? require('./webpack.prod.conf')
: require('./webpack.dev.conf')

// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port

// Define HTTP proxies to your custom API backend
// https://github.com/chimurai/http-proxy-middleware
var proxyTable = config.dev.proxyTable

var app = express()
var compiler = webpack(webpackConfig)

var devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
chunks: false
}
})

var hotMiddleware = require('webpack-hot-middleware')(compiler)
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
hotMiddleware.publish({ action: 'reload' })
cb()
})
})

// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
var options = proxyTable[context]
if (typeof options === 'string') {
options = { target: options }
}
app.use(proxyMiddleware(context, options))
})

// handle fallback for HTML5 history API
app.use(require('connect-history-api-fallback')())

// serve webpack bundle output
app.use(devMiddleware)

// enable hot-reload and state-preserving
// compilation error display
app.use(hotMiddleware)

// serve pure static assets
app.use('/statics', express.static('./src/statics'))

// try to serve Cordova statics for Play App
app.use(express.static(platform.cordovaAssets))

module.exports = app.listen(port, function (err) {
if (err) {
console.log(err)
return
}
console.log('Running with "' + (process.argv[2] || 'mat') + '" theme')
console.log('Listening at http://localhost:' + port + '\n')
console.log('Building. Please wait...')
})
57 changes: 57 additions & 0 deletions build/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var ExtractTextPlugin = require('extract-text-webpack-plugin')

exports.cssLoaders = function (options) {
options = options || {}

// generate loader string to be used with extract text plugin
function generateLoaders (loaders) {
if (options.postcss) {
loaders.splice(1, 0, 'postcss')
}

var sourceLoader = loaders.map(function (loader) {
var extraParamChar
if (/\?/.test(loader)) {
loader = loader.replace(/\?/, '-loader?')
extraParamChar = '&'
}
else {
loader = loader + '-loader'
extraParamChar = '?'
}
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
}).join('!')

if (options.extract) {
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
}
else {
return ['vue-style-loader', sourceLoader].join('!')
}
}

// http://vuejs.github.io/vue-loader/configurations/extract-css.html
return {
css: generateLoaders(['css']),
postcss: generateLoaders(['css']),
less: generateLoaders(['css', 'less']),
sass: generateLoaders(['css', 'sass?indentedSyntax']),
scss: generateLoaders(['css', 'sass']),
stylus: generateLoaders(['css', 'stylus']),
styl: generateLoaders(['css', 'stylus'])
}
}

// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
var output = []
var loaders = exports.cssLoaders(options)
for (var extension in loaders) {
var loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
loader: loader
})
}
return output
}
90 changes: 90 additions & 0 deletions build/webpack.base.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
var
path = require('path'),
webpack = require('webpack'),
config = require('../config'),
utils = require('./utils'),
projectRoot = path.resolve(__dirname, '../'),
autoprefixer = require('autoprefixer')

module.exports = {
entry: {
app: './src/app.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: process.env.NODE_ENV === 'production' ? config.build.publicPath : config.dev.publicPath,
filename: 'js/[name].js',
chunkFilename: 'js/[id].[chunkhash].js'
},
resolve: {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'quasar': path.resolve(__dirname, '../node_modules/quasar-framework/'),
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components'),
'helpers': path.resolve(__dirname, '../src/helpers'),
}
},
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')]
},
module: {
preLoaders: [
{
test: /\.(vue|js)$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.html$/,
loader: 'vue-html'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: 'img/[name].[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: 'fonts/[name].[hash:7].[ext]'
}
}
]
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
postcss: function () {
return [autoprefixer]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin()
]
}
37 changes: 37 additions & 0 deletions build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var
config = require('../config'),
webpack = require('webpack'),
merge = require('webpack-merge'),
utils = require('./utils'),
platform = require('./platform'),
baseWebpackConfig = require('./webpack.base.conf'),
HtmlWebpackPlugin = require('html-webpack-plugin')

// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
baseWebpackConfig.entry[name] = ['./build/hot-reload'].concat(baseWebpackConfig.entry[name])
})

module.exports = merge(baseWebpackConfig, {
module: {
loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, postcss: true })
},
// eval-source-map is faster for development
devtool: '#eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env,
'__THEME': '"' + platform.theme + '"'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
inject: true
})
],
vue: {
loaders: utils.cssLoaders()
}
})
Loading

0 comments on commit 9eb6ee7

Please sign in to comment.