Skip to content
This repository was archived by the owner on May 3, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions template/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
18 changes: 18 additions & 0 deletions template/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:8-alpine
RUN apk add --update bash && rm -rf /var/cache/apk/*
RUN apk add --update git && rm -rf /tmp/* /var/cache/apk/*
RUN npm install -g cordova quasar-cli
RUN cordova --version

WORKDIR /var/www

ENV NODE_ENV=development
COPY package.json /var/wwwpackage.json
RUN npm install

COPY . /var/www

EXPOSE 8080
VOLUME /var/www

CMD ["quasar", "dev"]
27 changes: 26 additions & 1 deletion template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,34 @@

> A Quasar project

## Build Setup
## Develop using docker
This will allow you to develop the quasar app in a docker container.

Open two terminals pointing to the same project root. Use one to run `docker-compose up` and another to ssh into the running container to run wanted commands with `npm run bash`

``` bash

# Run docker-compose in one terminal
$ docker-compose up

# ssh into the running container
$ npm run bash
```

To work with `quasar dev --play` you must use manually reference the ip port of your computer instead of the one used by the docker container.

``` bash

# On a mac
$ ifconfig
```

## Develop using local environment

### Build Setup

``` bash

# install dependencies
$ npm install

Expand Down
7 changes: 7 additions & 0 deletions template/build/script.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var
config = require('../config'),
webpack = require('webpack'),
webpackConfig = require('./webpack.prod.conf'),
renderSSR = require('./script.ssr'),
targetPath = path.join(__dirname, '../dist')

console.log(' WARNING!'.bold)
Expand All @@ -31,6 +32,12 @@ function finalize () {
console.log(' Opening index.html over file:// won\'t work.'.bold)
}

// Compile SSR
if (config.renderSSR) {
const renderSSR = require('./script.ssr')
renderSSR({ watch: false })
}

webpack(webpackConfig, function (err, stats) {
if (err) throw err

Expand Down
6 changes: 6 additions & 0 deletions template/build/script.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ if (config.dev.openBrowser) {
console.log(' Browser will open when build is ready.\n')
}

// Compile SSR
if (config.renderSSR) {
const renderSSR = require('./script.ssr')
renderSSR({ watch: true })
}

var compiler = webpack(webpackConfig)

// Define HTTP proxies to your custom API backend
Expand Down
27 changes: 27 additions & 0 deletions template/build/script.ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var
webpack = require('webpack'),
webpackSSRConfig = require('./webpack.ssr.conf')

// Compile SSR
module.exports = function renderSSRFile (overrideOptions) {

const config = Object.assign(
{}, webpackSSRConfig, overrideOptions
)

webpack(config, function (err, stats) {
if (err) throw err

process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false
}) + '\n')

if (stats.hasErrors()) {
process.exit(1)
}
})
}
2 changes: 1 addition & 1 deletion template/build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = merge(baseWebpackConfig, {
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
removeAttributeQuotes: false
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
Expand Down
81 changes: 81 additions & 0 deletions template/build/webpack.ssr.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
var
config = require('../config'),
webpack = require('webpack'),
merge = require('webpack-merge'),
cssUtils = require('./css-utils'),
{ cloneDeep } = require('lodash'),
baseWebpackConfig = require('./webpack.base.conf'),
path = require('path'),
FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')

const projectRoot = path.resolve(__dirname, '../')
const serverFolder = config.serverFolder || 'api'
const baseConfig = cloneDeep(baseWebpackConfig)

module.exports = Object.assign({}, baseConfig, {
target: 'node',
watch: true,
devServer: undefined,
devtool: '#cheap-module-eval-source-map',
entry: [
path.resolve(__dirname, `../${serverFolder}/vue-server-side-rendering.js`)
],
output: {
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, `../${serverFolder}/src/ssr/`),
filename: 'compiled-ssr.js',
},
module: {
rules: cssUtils.styleRules({
sourceMap: config.dev.cssSourceMap,
postcss: true
}).concat([
{
test: /\.js$/,
loader: 'babel-loader',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
postcss: cssUtils.postcss,
loaders: merge({js: 'babel-loader'}, cssUtils.styleLoaders({
sourceMap: false,
extract: false
}))
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'img/[name].[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'fonts/[name].[hash:7].[ext]'
}
}
])
},
plugins: baseConfig.plugins.concat([
new webpack.NoEmitOnErrorsPlugin(),
new FriendlyErrorsPlugin({
clearConsole: config.dev.clearConsoleOnRebuild
})
]),
performance: {
hints: false
}
})
3 changes: 3 additions & 0 deletions template/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module.exports = {
// Default theme to build with ('ios' or 'mat')
defaultTheme: 'mat',

serverFolder: 'api',
renderSSR: false,

build: {
env: require('./prod.env'),
publicPath: '',
Expand Down
10 changes: 10 additions & 0 deletions template/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'
services:
web:
build: .
container_name: 'quasar-dev'
ports:
- "8080:8080"
volumes:
- .:/var/www/:rw
- /var/www/node_modules
1 change: 1 addition & 0 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"clean": "node build/script.clean.js",
"dev": "node build/script.dev.js",
"build": "node build/script.build.js",
"bash": "docker exec -it quasar-dev bash",
"lint": "eslint --ext .js,.vue src"
},
"dependencies": {
Expand Down