├── .editorconfig ├── .gitignore ├── README.md ├── meta.js ├── package-lock.json ├── package.json └── template ├── .babelrc ├── .editorconfig ├── .gitignore ├── .nwjs-vue ├── dev-client.js ├── dev-runner.js ├── prod-builder.js ├── utils.js ├── webpack.bg.config.js └── webpack.main.config.js ├── README.md ├── package.json ├── src ├── bg │ └── bg.js └── main │ ├── App.vue │ ├── assets │ └── images │ │ └── logo.png │ ├── components │ └── LandingPage.vue │ ├── index.ejs │ ├── main.js │ ├── router │ └── index.js │ └── store │ ├── index.js │ └── modules │ ├── Counter.js │ └── index.js └── static └── .gitkeep /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nwjs-vue 2 | 3 | > A clean NW.js & Vue.js quick start boilerplate. 4 | 5 | ## Installation 6 | 7 | Install boilerplate: 8 | 9 | ``` bash 10 | npm install -g @vue/cli @vue/cli-init 11 | vue init elegantweb/nwjs-vue 12 | ``` 13 | 14 | Install dependencies: 15 | 16 | ``` bash 17 | cd 18 | npm install 19 | ``` 20 | 21 | ## Getting Started 22 | 23 | ### Development 24 | 25 | Specify target NW.js version in `package.json`: 26 | 27 | You can find available options [here](https://github.com/evshiron/nwjs-builder-phoenix). 28 | 29 | ``` 30 | { 31 | [...] 32 | "build": { 33 | [...] 34 | "nwVersion": "0.40.1", 35 | [...] 36 | }, 37 | [...] 38 | } 39 | ``` 40 | 41 | Run NW.js application for development: 42 | 43 | ``` bash 44 | npm run dev 45 | ``` 46 | 47 | ### Production 48 | 49 | Specify target platforms and architectures in `package.json`: 50 | 51 | You can find available options [here](https://github.com/evshiron/nwjs-builder-phoenix). 52 | 53 | ``` 54 | { 55 | [...] 56 | "build": { 57 | [...] 58 | "nwPlatforms": ["win"], 59 | "nwArchs": ["x64"], 60 | [...] 61 | }, 62 | [...] 63 | } 64 | ``` 65 | 66 | Build NW.js application for production: 67 | 68 | ``` bash 69 | npm run build 70 | ``` 71 | 72 | 73 | ## Alternatives 74 | 75 | * [NW Vue 3 Boilerplate](https://github.com/nwutils/nw-vue3-boilerplate) - NW.js + Vue 3 + Vite + Vitest + Vue-DevTools + Pinia 76 | * [nw-vue-cli-example](https://github.com/nwutils/nw-vue-cli-example) - Uses Vue-CLI, has Vue 2 and Vue 3 branches. 77 | * [vue-desktop-basic](https://github.com/TheJaredWilcurt/vue-desktop-basic) - Does not use a build system at all, all `.vue` files run directly in the browser context 78 | -------------------------------------------------------------------------------- /meta.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | prompts: { 3 | name: { 4 | type: 'string', 5 | required: true, 6 | message: 'Application name' 7 | }, 8 | label: { 9 | type: 'string', 10 | required: false, 11 | message: 'Application conventional name', 12 | default (data) { 13 | return data.name.replace(/((?:^|-|_)+[a-z])/g, ($1) => $1.toUpperCase().replace('-', '')) 14 | } 15 | }, 16 | description: { 17 | type: 'string', 18 | required: false, 19 | message: 'Application description', 20 | default: 'A nwjs-vue application' 21 | }, 22 | plugins: { 23 | type: 'checkbox', 24 | message: 'Select which Vue plugins to install', 25 | choices: ['axios', 'vue-router', 'vuex'], 26 | default: ['axios', 'vue-router', 'vuex'] 27 | } 28 | }, 29 | helpers: { 30 | isEnabled (list, check, opts) { 31 | if (list[check]) return opts.fn(this) 32 | else return opts.inverse(this) 33 | } 34 | }, 35 | filters: { 36 | 'app/main/router/**/*': 'plugins[\'vue-router\']', 37 | 'app/main/store/**/*': 'plugins[\'vuex\']' 38 | }, 39 | complete (data) { 40 | console.log() 41 | console.log(' Welcome to your new nwjs-vue project!') 42 | console.log() 43 | console.log(' Next steps:') 44 | if (!data.inPlace) console.log(` \x1b[33m$\x1b[0m cd ${data.destDirName}`) 45 | console.log(' \x1b[33m$\x1b[0m npm install') 46 | console.log(' \x1b[33m$\x1b[0m npm run dev') 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nwjs-vue", 3 | "version": "0.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nwjs-vue", 3 | "version": "0.0.0", 4 | "description": "A NW.js & Vue.js quick start boilerplate.", 5 | "license": "MIT", 6 | "main": "meta.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/elegantweb/nwjs-vue.git" 10 | }, 11 | "keywords": [ 12 | "nwjs", 13 | "vue", 14 | "boilerplate" 15 | ], 16 | "author": "Sina Sharifzade (github.com/sharifzadesina)", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/elegantweb/nwjs-vue/issues" 20 | }, 21 | "homepage": "https://github.com/elegantweb/nwjs-vue#readme" 22 | } 23 | -------------------------------------------------------------------------------- /template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "comments": false, 3 | "plugins": ["@babel/plugin-transform-runtime"], 4 | "env": { 5 | "main": { 6 | "presets": [["@babel/preset-env", { "modules": false }]] 7 | }, 8 | "bg": { 9 | "presets": [["@babel/preset-env", { "modules": false }]] 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /template/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | releases/ 3 | dist/ 4 | -------------------------------------------------------------------------------- /template/.nwjs-vue/dev-client.js: -------------------------------------------------------------------------------- 1 | const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 2 | 3 | hotClient.subscribe((event) => { 4 | switch (event.action) { 5 | case 'reload': 6 | onReload() 7 | break 8 | case 'compiling': 9 | onCompiling() 10 | break 11 | case 'compiled': 12 | onCompiled() 13 | break 14 | } 15 | }) 16 | 17 | function onReload () { 18 | window.location.reload() 19 | } 20 | 21 | function onCompiling () { 22 | document.body.innerHTML += '
Compiling...
' 23 | } 24 | 25 | function onCompiled () { 26 | nw.App.quit() 27 | } 28 | -------------------------------------------------------------------------------- /template/.nwjs-vue/dev-runner.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = 'development' 2 | 3 | const path = require('path') 4 | const { spawn } = require('child_process') 5 | const npmWhich = require('npm-which')(__dirname) 6 | const webpack = require('webpack') 7 | const WebpackDevServer = require('webpack-dev-server') 8 | const webpackHotMiddleware = require('webpack-hot-middleware') 9 | 10 | const webpackMainConfig = require('./webpack.main.config') 11 | const webpackBgConfig = require('./webpack.bg.config') 12 | 13 | const runPath = npmWhich.sync('run') 14 | 15 | let nwProcess = null 16 | let nwRestarting = false 17 | 18 | let mainHotMiddleware = null 19 | 20 | function createMainServer (config, callback) { 21 | // add dev-client file to webpack, so we will be able to handle hot middleware commands on browser 22 | config.entry.main = [path.join(__dirname, 'dev-client')].concat(config.entry.main) 23 | 24 | const compiler = webpack(config) 25 | 26 | mainHotMiddleware = webpackHotMiddleware(compiler, { 27 | log: false, 28 | heartbeat: 2500 29 | }) 30 | 31 | // force page reload when html-webpack-plugin template changes 32 | compiler.hooks.compilation.tap('compilation', (compilation) => { 33 | compilation.hooks.htmlWebpackPluginAfterEmit.tapAsync('html-webpack-plugin-after-emit', (data, cb) => { 34 | mainHotMiddleware.publish({ action: 'reload' }) 35 | cb() 36 | }) 37 | }) 38 | 39 | compiler.hooks.done.tap('done', (stats) => { 40 | console.log(stats.toString({ chunks: false, colors: true })) 41 | }) 42 | 43 | return new WebpackDevServer(compiler, { 44 | quiet: true, 45 | disableHostCheck: true, 46 | before (app, ctx) { 47 | app.use(mainHotMiddleware) 48 | ctx.middleware.waitUntilValid(() => { 49 | callback() 50 | }) 51 | } 52 | }) 53 | } 54 | 55 | function createBgServer (config, callback) { 56 | const compiler = webpack(config) 57 | 58 | compiler.hooks.watchRun.tapAsync('watch-run', (compilation, cb) => { 59 | console.log('Compiling background script...') 60 | mainHotMiddleware.publish({ action: 'compiling' }) 61 | cb() 62 | }) 63 | 64 | compiler.watch({}, (err, stats) => { 65 | if (err) console.error(err) 66 | else { 67 | console.log(stats.toString({ chunks: false, colors: true })) 68 | mainHotMiddleware.publish({ action: 'compiled' }) 69 | if (nwProcess) nwRestarting = true 70 | callback() 71 | } 72 | }) 73 | } 74 | 75 | function createNwProcess (callback) { 76 | nwProcess = spawn(runPath, ['.']) 77 | 78 | nwProcess.stdout.on('data', (data) => { 79 | const msg = data.toString('utf8') 80 | console.log(msg) 81 | if (msg.includes('Launching NW.js app')) { 82 | callback() 83 | } 84 | }) 85 | 86 | nwProcess.stderr.on('data', (data) => { 87 | const msg = data.toString('utf8') 88 | console.error(msg) 89 | }) 90 | 91 | nwProcess.on('close', () => { 92 | if (nwRestarting) startNw().then(() => { nwRestarting = false }) 93 | else process.exit() 94 | }) 95 | } 96 | 97 | function startMain () { 98 | return new Promise((resolve, reject) => { 99 | createMainServer(webpackMainConfig, resolve).listen(9080) 100 | }) 101 | } 102 | 103 | function startBg () { 104 | return new Promise((resolve, reject) => { 105 | createBgServer(webpackBgConfig, resolve) 106 | }) 107 | } 108 | 109 | function startNw () { 110 | return new Promise((resolve, reject) => { 111 | createNwProcess(resolve) 112 | }) 113 | } 114 | 115 | async function main () { 116 | await Promise.all([startMain(), startBg()]) 117 | startNw() 118 | } 119 | 120 | main() 121 | -------------------------------------------------------------------------------- /template/.nwjs-vue/prod-builder.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = 'production' 2 | 3 | const fs = require('fs-extra') 4 | const path = require('path') 5 | const { spawnSync } = require('child_process') 6 | const npmWhich = require('npm-which')(__dirname) 7 | const webpack = require('webpack') 8 | 9 | const webpackMainConfig = require('./webpack.main.config') 10 | const webpackBgConfig = require('./webpack.bg.config') 11 | 12 | const manifest = require('../package') 13 | 14 | const buildPath = npmWhich.sync('build') 15 | 16 | function cleanDist () { 17 | return fs.emptydir(path.resolve(__dirname, '../', 'dist')) 18 | } 19 | 20 | function cleanBuild () { 21 | return fs.emptydir(path.resolve(__dirname, '../', manifest.build.output)) 22 | } 23 | 24 | function pack (config) { 25 | return new Promise((resolve, reject) => { 26 | webpack(config, (err, stats) => { 27 | if (err) reject(err) 28 | else if (stats.hasErrors()) reject(stats.toString({ chunks: false, colors: true })) 29 | else resolve() 30 | }) 31 | }) 32 | } 33 | 34 | function packMain () { 35 | return pack(webpackMainConfig) 36 | } 37 | 38 | function packBg () { 39 | return pack(webpackBgConfig) 40 | } 41 | 42 | function build () { 43 | manifest.build.nwPlatforms.forEach((os) => { 44 | manifest.build.nwArchs.forEach((arch) => { 45 | spawnSync(buildPath, [`--${os}`, `--${arch}`, '.'], { stdio: 'inherit' }) 46 | }) 47 | }) 48 | } 49 | 50 | async function main () { 51 | await Promise.all([cleanDist(), cleanBuild()]) 52 | await Promise.all([packMain(), packBg()]) 53 | build() 54 | } 55 | 56 | main() 57 | -------------------------------------------------------------------------------- /template/.nwjs-vue/utils.js: -------------------------------------------------------------------------------- 1 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 2 | 3 | const isProduction = process.env.NODE_ENV === 'production' 4 | 5 | function generateLoader (loader, options) { 6 | return { 7 | loader: loader + '-loader', 8 | options: { 9 | sourceMap: options.sourceMap 10 | } 11 | } 12 | } 13 | 14 | // see: https://vue-loader.vuejs.org/guide/extract-css.html#webpack-4 15 | function generateExtracter (options) { 16 | return { 17 | loader: MiniCssExtractPlugin.loader, 18 | options: { 19 | hmr: !isProduction 20 | } 21 | } 22 | } 23 | 24 | function generateLoaders (loader, options) { 25 | let loaders = [] 26 | if (options.extract) loaders.push(generateExtracter(options)) 27 | else loaders.push('vue-style-loader') 28 | if (loader != 'css') loaders.push(generateLoader('css', options)) 29 | loaders.push(generateLoader(loader, options)) 30 | return loaders 31 | } 32 | 33 | function generateStyleLoader (extension, loader) { 34 | return { 35 | test: new RegExp('\\.' + extension + '$'), 36 | use: loader 37 | } 38 | } 39 | 40 | exports.cssLoaders = function (options) { 41 | return { 42 | css: generateLoaders('css', options), 43 | postcss: generateLoaders('css', options), 44 | less: generateLoaders('less', options), 45 | sass: generateLoaders('sass', Object.assign({}, options, { indentedSyntax: true })), 46 | scss: generateLoaders('sass', options), 47 | stylus: generateLoaders('stylus', options), 48 | styl: generateLoaders('stylus', options) 49 | } 50 | } 51 | 52 | // Generate loaders for standalone style files 53 | exports.styleLoaders = function (options) { 54 | let output = [], loaders = exports.cssLoaders(options) 55 | for (let ext in loaders) output.push(generateStyleLoader(ext, loaders[ext])) 56 | return output 57 | } 58 | -------------------------------------------------------------------------------- /template/.nwjs-vue/webpack.bg.config.js: -------------------------------------------------------------------------------- 1 | process.env.BABEL_ENV = 'bg' 2 | 3 | const path = require('path') 4 | const webpack = require('webpack') 5 | const TerserJSPlugin = require('terser-webpack-plugin') 6 | 7 | const utils = require('./utils') 8 | const { dependencies } = require('../package') 9 | 10 | const isProduction = process.env.NODE_ENV === 'production' 11 | 12 | let config = { 13 | mode: isProduction ? 'production' : 'development', 14 | devtool: '#cheap-module-eval-source-map', 15 | target: 'node-webkit', 16 | entry: { 17 | bg: path.join(__dirname, '../src/bg/bg') 18 | }, 19 | output: { 20 | path: path.join(__dirname, '../dist/bg'), 21 | filename: '[name].js' 22 | }, 23 | externals: [ 24 | // Externalize all dependencies inside of the application directory. 25 | function (context, request, callback) { 26 | if (dependencies && dependencies[request]) { 27 | return callback(null, 'commonjs ' + request) 28 | } else { 29 | callback() 30 | } 31 | } 32 | ], 33 | module: { 34 | rules: [ 35 | { 36 | test: /\.js$/, 37 | loader: 'babel-loader', 38 | exclude: /node_modules/ 39 | } 40 | ] 41 | }, 42 | resolve: { 43 | extensions: ['.js', '.json'], 44 | alias: { 45 | '@': path.join(__dirname, '../src/bg') 46 | } 47 | }, 48 | optimization: { 49 | minimizer: [ 50 | new TerserJSPlugin({ 51 | terserOptions: { 52 | output: { comments: false } 53 | } 54 | }) 55 | ] 56 | }, 57 | plugins: [ 58 | new webpack.NoEmitOnErrorsPlugin() 59 | ] 60 | } 61 | 62 | if (!isProduction) { 63 | config.plugins.push( 64 | new webpack.DefinePlugin({ 65 | '__static': JSON.stringify(path.join(__dirname, '../static')) 66 | }) 67 | ) 68 | } 69 | 70 | if (isProduction) { 71 | config.devtool = false 72 | config.plugins.push( 73 | new webpack.DefinePlugin({ 74 | '__static': '"dist/static"' 75 | }) 76 | ) 77 | } 78 | 79 | module.exports = config 80 | -------------------------------------------------------------------------------- /template/.nwjs-vue/webpack.main.config.js: -------------------------------------------------------------------------------- 1 | process.env.BABEL_ENV = 'main' 2 | 3 | const path = require('path') 4 | const webpack = require('webpack') 5 | const HtmlWebpackPlugin = require('html-webpack-plugin') 6 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 7 | const TerserJSPlugin = require('terser-webpack-plugin') 8 | const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') 9 | const CopyWebpackPlugin = require('copy-webpack-plugin') 10 | const VueLoaderPlugin = require('vue-loader/lib/plugin') 11 | 12 | const utils = require('./utils') 13 | const { label, dependencies } = require('../package') 14 | 15 | const isProduction = process.env.NODE_ENV === 'production' 16 | 17 | let config = { 18 | mode: isProduction ? 'production' : 'development', 19 | devtool: '#cheap-module-eval-source-map', 20 | target: 'node-webkit', 21 | entry: { 22 | main: path.join(__dirname, '../src/main/main') 23 | }, 24 | output: { 25 | path: path.join(__dirname, '../dist/main'), 26 | filename: '[name].js' 27 | }, 28 | externals: [ 29 | // Externalize all dependencies inside of the application directory. 30 | function (context, request, callback) { 31 | if (dependencies && dependencies[request]) { 32 | return callback(null, 'commonjs ' + request) 33 | } else { 34 | callback() 35 | } 36 | } 37 | ], 38 | module: { 39 | rules: [ 40 | ...utils.styleLoaders({ 41 | sourceMap: !isProduction, 42 | extract: isProduction 43 | }), 44 | { 45 | test: /\.js$/, 46 | loader: 'babel-loader', 47 | exclude: /node_modules/ 48 | }, 49 | { 50 | test: /\.vue$/, 51 | loader: 'vue-loader', 52 | }, 53 | { 54 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 55 | use: { 56 | loader: 'url-loader', 57 | query: { 58 | limit: 10000, 59 | name: 'img/[name].[hash:7].[ext]' 60 | } 61 | } 62 | }, 63 | { 64 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 65 | loader: 'url-loader', 66 | options: { 67 | limit: 10000, 68 | name: 'media/[name].[hash:7].[ext]' 69 | } 70 | }, 71 | { 72 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 73 | use: { 74 | loader: 'url-loader', 75 | query: { 76 | limit: 10000, 77 | name: 'fonts/[name].[hash:7].[ext]' 78 | } 79 | } 80 | } 81 | ] 82 | }, 83 | resolve: { 84 | extensions: ['.js', '.vue', '.json'], 85 | alias: { 86 | '@': path.join(__dirname, '../src/main'), 87 | // see: https://vuejs.org/v2/guide/installation.html#Terms 88 | 'vue$': 'vue/dist/vue.esm.js' 89 | } 90 | }, 91 | optimization: { 92 | minimizer: [ 93 | new TerserJSPlugin({ 94 | terserOptions: { 95 | output: { comments: false } 96 | } 97 | }), 98 | new OptimizeCSSAssetsPlugin({ 99 | cssProcessorPluginOptions: { 100 | preset: ['default', { discardComments: { removeAll: true } }], 101 | } 102 | }) 103 | ] 104 | }, 105 | plugins: [ 106 | new webpack.HotModuleReplacementPlugin(), 107 | new webpack.NoEmitOnErrorsPlugin(), 108 | new VueLoaderPlugin(), 109 | new MiniCssExtractPlugin({ filename: 'style.css' }), 110 | new HtmlWebpackPlugin({ 111 | title: label, 112 | filename: 'index.html', 113 | template: path.join(__dirname, '../src/main/index.ejs'), 114 | minify: { 115 | collapseWhitespace: true, 116 | removeAttributeQuotes: true, 117 | removeComments: true 118 | } 119 | }) 120 | ] 121 | } 122 | 123 | if (!isProduction) { 124 | config.plugins.push( 125 | new webpack.DefinePlugin({ 126 | '__static': JSON.stringify(path.join(__dirname, '../static')) 127 | }) 128 | ) 129 | } 130 | 131 | if (isProduction) { 132 | config.devtool = false 133 | config.plugins.push( 134 | new webpack.DefinePlugin({ 135 | '__static': '"dist/static"' 136 | }), 137 | new CopyWebpackPlugin([ 138 | { 139 | from: path.join(__dirname, '../static'), 140 | to: path.join(__dirname, '../dist/static'), 141 | ignore: ['.*'] 142 | } 143 | ]) 144 | ) 145 | } 146 | 147 | module.exports = config 148 | -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # {{ name }} 2 | 3 | > {{ description }} 4 | 5 | #### Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # run NW.js application for development 12 | npm run dev 13 | 14 | # build NW.js application for production 15 | npm run build 16 | ``` 17 | 18 | --- 19 | 20 | This project was generated with [nwjs-vue](https://github.com/elegantweb/nwjs-vue) using [vue-cli](https://github.com/vuejs/vue-cli). 21 | -------------------------------------------------------------------------------- /template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{ name }}", 3 | "label": "{{ label }}", 4 | "description": "{{ description }}", 5 | "version": "1.0.0", 6 | "author": "{{ author }}", 7 | "private": true, 8 | "main": "http://localhost:9080", 9 | "node-remote": "*://localhost/*", 10 | "bg-script": "./dist/bg/bg.js", 11 | "window": { 12 | "width": 1000, 13 | "height": 563 14 | }, 15 | "build": { 16 | "files": [ 17 | "node_modules/**/*", 18 | "dist/**/*" 19 | ], 20 | "output": "./releases", 21 | "nwVersion": "0.40.1", 22 | "nwPlatforms": [ 23 | "win" 24 | ], 25 | "nwArchs": [ 26 | "x64" 27 | ], 28 | "strippedProperties": [ 29 | "label", 30 | "private", 31 | "scripts", 32 | "devDependencies", 33 | "build" 34 | ], 35 | "overriddenProperties": { 36 | "main": "./dist/main/index.html" 37 | } 38 | }, 39 | "scripts": { 40 | "dev": "node .nwjs-vue/dev-runner.js", 41 | "build": "node .nwjs-vue/prod-builder.js" 42 | }, 43 | "devDependencies": { 44 | "@babel/core": "^7.5.5", 45 | "@babel/plugin-transform-runtime": "^7.5.5", 46 | "@babel/preset-env": "^7.5.5", 47 | "ajv": "^6.10.2", 48 | {{#isEnabled plugins 'axios'}} 49 | "axios": "^0.19.0", 50 | {{/isEnabled}} 51 | "babel-loader": "^8.0.6", 52 | "copy-webpack-plugin": "^5.0.4", 53 | "css-loader": "^3.2.0", 54 | "file-loader": "^4.2.0", 55 | "fs-extra": "^8.1.0", 56 | "html-webpack-plugin": "^3.2.0", 57 | "mini-css-extract-plugin": "^0.8.0", 58 | "node-sass": "^4.12.0", 59 | "npm-which": "^3.0.1", 60 | "nwjs-builder-phoenix": "^1.15.0", 61 | "optimize-css-assets-webpack-plugin": "^5.0.3", 62 | "sass-loader": "^7.3.1", 63 | "url-loader": "^2.1.0", 64 | "vue": "^2.6.10", 65 | "vue-loader": "^15.7.1", 66 | {{#isEnabled plugins 'vue-router'}} 67 | "vue-router": "^3.1.2", 68 | {{/isEnabled}} 69 | "vue-template-compiler": "^2.6.10", 70 | {{#isEnabled plugins 'vuex'}} 71 | "vuex": "^3.1.1", 72 | {{/isEnabled}} 73 | "webpack": "^4.39.2", 74 | "webpack-dev-server": "^3.8.0", 75 | "webpack-hot-middleware": "^2.25.0" 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /template/src/bg/bg.js: -------------------------------------------------------------------------------- 1 | console.log('We are at bg-script!') 2 | -------------------------------------------------------------------------------- /template/src/main/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 25 | 26 | 34 | -------------------------------------------------------------------------------- /template/src/main/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elegantweb/nwjs-vue/3fb299aed269d9b2ffe42dbc7b44aa35a53db9ba/template/src/main/assets/images/logo.png -------------------------------------------------------------------------------- /template/src/main/components/LandingPage.vue: -------------------------------------------------------------------------------- 1 | 21 | 22 | 32 | 33 | 34 | 53 | -------------------------------------------------------------------------------- /template/src/main/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= htmlWebpackPlugin.options.title %> 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /template/src/main/main.js: -------------------------------------------------------------------------------- 1 | {{#isEnabled plugins 'axios'}} 2 | import axios from 'axios' 3 | {{/isEnabled}} 4 | import Vue from 'vue' 5 | 6 | import App from './App.vue' 7 | {{#isEnabled plugins 'vue-router'}} 8 | import router from './router' 9 | {{/isEnabled}} 10 | {{#isEnabled plugins 'vuex'}} 11 | import store from './store' 12 | {{/isEnabled}} 13 | 14 | {{#isEnabled plugins 'axios'}} 15 | Vue.http = Vue.prototype.$http = axios 16 | {{/isEnabled}} 17 | 18 | Vue.config.productionTip = false 19 | 20 | new Vue({ 21 | el: '#app', 22 | {{#isEnabled plugins 'vue-router'}} 23 | router, 24 | {{/isEnabled}} 25 | {{#isEnabled plugins 'vuex'}} 26 | store, 27 | {{/isEnabled}} 28 | render: h => h(App) 29 | }) 30 | -------------------------------------------------------------------------------- /template/src/main/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | Vue.use(VueRouter) 5 | 6 | export default new VueRouter({ 7 | routes: [ 8 | { 9 | path: '/', 10 | name: 'landing-page', 11 | component: require('@/components/LandingPage').default 12 | }, 13 | { 14 | path: '*', 15 | redirect: '/' 16 | } 17 | ] 18 | }) 19 | -------------------------------------------------------------------------------- /template/src/main/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | import modules from './modules' 5 | 6 | Vue.use(Vuex) 7 | 8 | export default new Vuex.Store({ 9 | modules, 10 | strict: process.env.NODE_ENV !== 'production' 11 | }) 12 | -------------------------------------------------------------------------------- /template/src/main/store/modules/Counter.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | main: 0 3 | } 4 | 5 | const getters = { 6 | } 7 | 8 | const mutations = { 9 | DECREMENT_MAIN_COUNTER (state) { 10 | state.main-- 11 | }, 12 | INCREMENT_MAIN_COUNTER (state) { 13 | state.main++ 14 | } 15 | } 16 | 17 | const actions = { 18 | } 19 | 20 | export default { 21 | state, 22 | getters, 23 | mutations, 24 | actions 25 | } 26 | -------------------------------------------------------------------------------- /template/src/main/store/modules/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The file enables `@/store/index.js` to import all vuex modules 3 | * in a one-shot manner. There should not be any reason to edit this file. 4 | */ 5 | 6 | const files = require.context('.', false, /\.js$/) 7 | const modules = {} 8 | 9 | files.keys().forEach(key => { 10 | if (key === './index.js') return 11 | modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default 12 | }) 13 | 14 | export default modules 15 | -------------------------------------------------------------------------------- /template/static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elegantweb/nwjs-vue/3fb299aed269d9b2ffe42dbc7b44aa35a53db9ba/template/static/.gitkeep --------------------------------------------------------------------------------