├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitattributes
├── .gitignore
├── .postcssrc.js
├── License.md
├── README.md
├── build
├── build.js
├── check-versions.js
├── dev-client.js
├── dev-server.js
├── utils.js
├── vue-loader.conf.js
├── webpack.base.conf.js
├── webpack.dev.conf.js
└── webpack.prod.conf.js
├── config
├── dev.env.js
├── index.js
└── prod.env.js
├── docs
├── structure.png
├── structure.svg
├── structure.vsdx
└── vs-code-folder-structure.png
├── index.html
├── package.json
├── src
├── App.vue
├── api
│ └── index.js
├── assets
│ └── .gitkeep
├── components
│ ├── ChatList.vue
│ ├── ChatListElement.vue
│ ├── ProductList.vue
│ └── ProductListElement.vue
├── main.js
├── router
│ └── index.js
├── store
│ ├── index.js
│ └── modules
│ │ ├── chat.js
│ │ └── products.js
├── util
│ └── .gitkeep
└── views
│ └── Home.vue
├── static
└── .gitkeep
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "env",
5 | {
6 | "modules": false,
7 | "targets": {
8 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
9 | }
10 | }
11 | ],
12 | "stage-2"
13 | ],
14 | "plugins": ["transform-runtime"],
15 | "env": {
16 | "test": {
17 | "presets": ["env", "stage-2"],
18 | "plugins": ["istanbul"]
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // https://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parser: 'babel-eslint',
6 | parserOptions: {
7 | sourceType: 'module',
8 | },
9 | env: {
10 | browser: true,
11 | },
12 | extends: 'airbnb-base',
13 | // required to lint *.vue files
14 | plugins: ['html'],
15 | // check if imports actually resolve
16 | settings: {
17 | 'import/resolver': {
18 | webpack: {
19 | config: 'build/webpack.base.conf.js',
20 | },
21 | },
22 | },
23 | // add your custom rules here
24 | rules: {
25 | // don't require .vue extension when importing
26 | 'import/extensions': [
27 | 'error',
28 | 'always',
29 | {
30 | js: 'never',
31 | vue: 'never',
32 | },
33 | ],
34 | // allow optionalDependencies
35 | 'import/no-extraneous-dependencies': [
36 | 'error',
37 | {
38 | optionalDependencies: ['test/unit/index.js'],
39 | },
40 | ],
41 | // allow debugger during development
42 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
43 | 'no-param-reassign': [
44 | 'error',
45 | { props: true, ignorePropertyModificationsFor: ['state'] },
46 | ],
47 | },
48 | };
49 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Editor directories and files
9 | .idea
10 | .vscode
11 | *.suo
12 | *.ntvs*
13 | *.njsproj
14 | *.sln
15 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserslist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | # The MIT License (MIT)
2 |
3 | Copyright (c) 2017-present Kevin Peters
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vuex-simple-structure by igeligel
2 |
3 | > A Vue.js/Vuex project showcasing a simple store structure. This project was
4 | > created in cooperation with [3yourmind](https://github.com/3YOURMIND).
5 |
6 |
7 |
8 |
9 |
10 |
11 | ## Showcase/Architecture
12 |
13 | Simple store structure containing just one main store and several module files.
14 |
15 |
16 | diagram
17 |
18 |
19 |
20 |
21 | file structure
22 |
23 |
24 |
25 | ## Dependencies
26 |
27 |
28 | npm dependencies
29 |
30 | | Dependency | Version |
31 | | ---------- | ------- |
32 | | vue | ^2.5.2 |
33 | | vue-router | ^3.0.1 |
34 | | vuex | ^3.0.0 |
35 |
36 |
37 |
38 | ## Installation
39 |
40 | The installation process is split into two sections for
41 | [development](#development) and [production](#production) use. You can find a
42 | production version of this site live at
43 | [vuex-simple-structure.netlify.com](https://vuex-simple-structure.netlify.com/).
44 |
45 | ### Development
46 |
47 |
48 | instructions
49 |
50 | #### Using npm
51 |
52 | ```shell
53 | npm install
54 | npm run dev
55 | ```
56 |
57 | #### Using yarn
58 |
59 | ```shell
60 | yarn install
61 | yarn run dev
62 | ```
63 |
64 |
65 |
66 | ### Production
67 |
68 |
69 | instructions
70 |
71 | #### Using npm
72 |
73 | ```shell
74 | npm install
75 | npm run build
76 | ```
77 |
78 | #### Using yarn
79 |
80 | ```shell
81 | yarn install
82 | yarn run build
83 | ```
84 |
85 |
86 |
87 | ## Examples
88 |
89 | * [vuejs/vuex - shopping cart example](https://github.com/vuejs/vuex/tree/dev/examples/shopping-cart)
90 | * [igeligel/vuex-simple-structure](https://github.com/igeligel/vuex-simple-structure)
91 |
92 | ## Contact
93 |
94 |
95 |
96 | ## Contributors
97 |
98 |
99 |
100 | ## License
101 |
102 | _vuex-simple-structure_ is realeased under the [MIT License](/License.md).
103 |
--------------------------------------------------------------------------------
/build/build.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | require('./check-versions')()
3 |
4 | process.env.NODE_ENV = 'production'
5 |
6 | const ora = require('ora')
7 | const rm = require('rimraf')
8 | const path = require('path')
9 | const chalk = require('chalk')
10 | const webpack = require('webpack')
11 | const config = require('../config')
12 | const webpackConfig = require('./webpack.prod.conf')
13 |
14 | const spinner = ora('building for production...')
15 | spinner.start()
16 |
17 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
18 | if (err) throw err
19 | webpack(webpackConfig, function (err, stats) {
20 | spinner.stop()
21 | if (err) throw err
22 | process.stdout.write(stats.toString({
23 | colors: true,
24 | modules: false,
25 | children: false,
26 | chunks: false,
27 | chunkModules: false
28 | }) + '\n\n')
29 |
30 | if (stats.hasErrors()) {
31 | console.log(chalk.red(' Build failed with errors.\n'))
32 | process.exit(1)
33 | }
34 |
35 | console.log(chalk.cyan(' Build complete.\n'))
36 | console.log(chalk.yellow(
37 | ' Tip: built files are meant to be served over an HTTP server.\n' +
38 | ' Opening index.html over file:// won\'t work.\n'
39 | ))
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/build/check-versions.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const chalk = require('chalk')
3 | const semver = require('semver')
4 | const packageConfig = require('../package.json')
5 | const shell = require('shelljs')
6 | function exec (cmd) {
7 | return require('child_process').execSync(cmd).toString().trim()
8 | }
9 |
10 | const versionRequirements = [
11 | {
12 | name: 'node',
13 | currentVersion: semver.clean(process.version),
14 | versionRequirement: packageConfig.engines.node
15 | }
16 | ]
17 |
18 | if (shell.which('npm')) {
19 | versionRequirements.push({
20 | name: 'npm',
21 | currentVersion: exec('npm --version'),
22 | versionRequirement: packageConfig.engines.npm
23 | })
24 | }
25 |
26 | module.exports = function () {
27 | const warnings = []
28 | for (let i = 0; i < versionRequirements.length; i++) {
29 | const mod = versionRequirements[i]
30 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
31 | warnings.push(mod.name + ': ' +
32 | chalk.red(mod.currentVersion) + ' should be ' +
33 | chalk.green(mod.versionRequirement)
34 | )
35 | }
36 | }
37 |
38 | if (warnings.length) {
39 | console.log('')
40 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
41 | console.log()
42 | for (let i = 0; i < warnings.length; i++) {
43 | const warning = warnings[i]
44 | console.log(' ' + warning)
45 | }
46 | console.log()
47 | process.exit(1)
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/build/dev-client.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | 'use strict'
3 | require('eventsource-polyfill')
4 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
5 |
6 | hotClient.subscribe(function (event) {
7 | if (event.action === 'reload') {
8 | window.location.reload()
9 | }
10 | })
11 |
--------------------------------------------------------------------------------
/build/dev-server.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | require('./check-versions')()
3 |
4 | const config = require('../config')
5 | if (!process.env.NODE_ENV) {
6 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
7 | }
8 |
9 | const opn = require('opn')
10 | const path = require('path')
11 | const express = require('express')
12 | const webpack = require('webpack')
13 | const proxyMiddleware = require('http-proxy-middleware')
14 | const webpackConfig = require('./webpack.dev.conf')
15 |
16 | // default port where dev server listens for incoming traffic
17 | const port = process.env.PORT || config.dev.port
18 | // automatically open browser, if not set will be false
19 | const autoOpenBrowser = !!config.dev.autoOpenBrowser
20 | // Define HTTP proxies to your custom API backend
21 | // https://github.com/chimurai/http-proxy-middleware
22 | const proxyTable = config.dev.proxyTable
23 |
24 | const app = express()
25 | const compiler = webpack(webpackConfig)
26 |
27 | const devMiddleware = require('webpack-dev-middleware')(compiler, {
28 | publicPath: webpackConfig.output.publicPath,
29 | quiet: true
30 | })
31 |
32 | const hotMiddleware = require('webpack-hot-middleware')(compiler, {
33 | log: false,
34 | heartbeat: 2000
35 | })
36 | // force page reload when html-webpack-plugin template changes
37 | // currently disabled until this is resolved:
38 | // https://github.com/jantimon/html-webpack-plugin/issues/680
39 | // compiler.plugin('compilation', function (compilation) {
40 | // compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
41 | // hotMiddleware.publish({ action: 'reload' })
42 | // cb()
43 | // })
44 | // })
45 |
46 | // enable hot-reload and state-preserving
47 | // compilation error display
48 | app.use(hotMiddleware)
49 |
50 | // proxy api requests
51 | Object.keys(proxyTable).forEach(function (context) {
52 | let options = proxyTable[context]
53 | if (typeof options === 'string') {
54 | options = { target: options }
55 | }
56 | app.use(proxyMiddleware(options.filter || context, options))
57 | })
58 |
59 | // handle fallback for HTML5 history API
60 | app.use(require('connect-history-api-fallback')())
61 |
62 | // serve webpack bundle output
63 | app.use(devMiddleware)
64 |
65 | // serve pure static assets
66 | const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
67 | app.use(staticPath, express.static('./static'))
68 |
69 | const uri = 'http://localhost:' + port
70 |
71 | var _resolve
72 | var _reject
73 | var readyPromise = new Promise((resolve, reject) => {
74 | _resolve = resolve
75 | _reject = reject
76 | })
77 |
78 | var server
79 | var portfinder = require('portfinder')
80 | portfinder.basePort = port
81 |
82 | console.log('> Starting dev server...')
83 | devMiddleware.waitUntilValid(() => {
84 | portfinder.getPort((err, port) => {
85 | if (err) {
86 | _reject(err)
87 | }
88 | process.env.PORT = port
89 | var uri = 'http://localhost:' + port
90 | console.log('> Listening at ' + uri + '\n')
91 | // when env is testing, don't need open it
92 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
93 | opn(uri)
94 | }
95 | server = app.listen(port)
96 | _resolve()
97 | })
98 | })
99 |
100 | module.exports = {
101 | ready: readyPromise,
102 | close: () => {
103 | server.close()
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/build/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const config = require('../config')
4 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
5 |
6 | exports.assetsPath = function (_path) {
7 | const assetsSubDirectory = process.env.NODE_ENV === 'production'
8 | ? config.build.assetsSubDirectory
9 | : config.dev.assetsSubDirectory
10 | return path.posix.join(assetsSubDirectory, _path)
11 | }
12 |
13 | exports.cssLoaders = function (options) {
14 | options = options || {}
15 |
16 | const cssLoader = {
17 | loader: 'css-loader',
18 | options: {
19 | minimize: process.env.NODE_ENV === 'production',
20 | sourceMap: options.sourceMap
21 | }
22 | }
23 |
24 | // generate loader string to be used with extract text plugin
25 | function generateLoaders (loader, loaderOptions) {
26 | const loaders = [cssLoader]
27 | if (loader) {
28 | loaders.push({
29 | loader: loader + '-loader',
30 | options: Object.assign({}, loaderOptions, {
31 | sourceMap: options.sourceMap
32 | })
33 | })
34 | }
35 |
36 | // Extract CSS when that option is specified
37 | // (which is the case during production build)
38 | if (options.extract) {
39 | return ExtractTextPlugin.extract({
40 | use: loaders,
41 | fallback: 'vue-style-loader'
42 | })
43 | } else {
44 | return ['vue-style-loader'].concat(loaders)
45 | }
46 | }
47 |
48 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html
49 | return {
50 | css: generateLoaders(),
51 | postcss: generateLoaders(),
52 | less: generateLoaders('less'),
53 | sass: generateLoaders('sass', { indentedSyntax: true }),
54 | scss: generateLoaders('sass'),
55 | stylus: generateLoaders('stylus'),
56 | styl: generateLoaders('stylus')
57 | }
58 | }
59 |
60 | // Generate loaders for standalone style files (outside of .vue)
61 | exports.styleLoaders = function (options) {
62 | const output = []
63 | const loaders = exports.cssLoaders(options)
64 | for (const extension in loaders) {
65 | const loader = loaders[extension]
66 | output.push({
67 | test: new RegExp('\\.' + extension + '$'),
68 | use: loader
69 | })
70 | }
71 | return output
72 | }
73 |
--------------------------------------------------------------------------------
/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const utils = require('./utils')
3 | const config = require('../config')
4 | const isProduction = process.env.NODE_ENV === 'production'
5 |
6 | module.exports = {
7 | loaders: utils.cssLoaders({
8 | sourceMap: isProduction
9 | ? config.build.productionSourceMap
10 | : config.dev.cssSourceMap,
11 | extract: isProduction
12 | }),
13 | transformToRequire: {
14 | video: 'src',
15 | source: 'src',
16 | img: 'src',
17 | image: 'xlink:href'
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const utils = require('./utils')
4 | const config = require('../config')
5 | const vueLoaderConfig = require('./vue-loader.conf')
6 | const { VueLoaderPlugin } = require('vue-loader')
7 |
8 | function resolve (dir) {
9 | return path.join(__dirname, '..', dir)
10 | }
11 |
12 | module.exports = {
13 | entry: {
14 | app: './src/main.js'
15 | },
16 | output: {
17 | path: config.build.assetsRoot,
18 | filename: '[name].js',
19 | publicPath: process.env.NODE_ENV === 'production'
20 | ? config.build.assetsPublicPath
21 | : config.dev.assetsPublicPath
22 | },
23 | resolve: {
24 | extensions: ['.js', '.vue', '.json'],
25 | alias: {
26 | 'vue$': 'vue/dist/vue.esm.js',
27 | '@': resolve('src'),
28 | }
29 | },
30 | plugins: [
31 | new VueLoaderPlugin()
32 | ],
33 | module: {
34 | rules: [
35 | {
36 | test: /\.(js|vue)$/,
37 | loader: 'eslint-loader',
38 | enforce: 'pre',
39 | include: [resolve('src'), resolve('test')],
40 | options: {
41 | formatter: require('eslint-friendly-formatter')
42 | }
43 | },
44 | {
45 | test: /\.vue$/,
46 | loader: 'vue-loader',
47 | options: vueLoaderConfig
48 | },
49 | {
50 | test: /\.js$/,
51 | loader: 'babel-loader',
52 | include: [resolve('src'), resolve('test')]
53 | },
54 | {
55 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
56 | loader: 'url-loader',
57 | options: {
58 | limit: 10000,
59 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
60 | }
61 | },
62 | {
63 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
64 | loader: 'url-loader',
65 | options: {
66 | limit: 10000,
67 | name: utils.assetsPath('media/[name].[hash:7].[ext]')
68 | }
69 | },
70 | {
71 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
72 | loader: 'url-loader',
73 | options: {
74 | limit: 10000,
75 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
76 | }
77 | }
78 | ]
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/build/webpack.dev.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const utils = require('./utils')
3 | const webpack = require('webpack')
4 | const config = require('../config')
5 | const merge = require('webpack-merge')
6 | const baseWebpackConfig = require('./webpack.base.conf')
7 | const HtmlWebpackPlugin = require('html-webpack-plugin')
8 | const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
9 |
10 | // add hot-reload related code to entry chunks
11 | Object.keys(baseWebpackConfig.entry).forEach(function (name) {
12 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
13 | })
14 |
15 | module.exports = merge(baseWebpackConfig, {
16 | module: {
17 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
18 | },
19 | // cheap-module-eval-source-map is faster for development
20 | devtool: '#cheap-module-eval-source-map',
21 | plugins: [
22 | new webpack.DefinePlugin({
23 | 'process.env': config.dev.env
24 | }),
25 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
26 | new webpack.HotModuleReplacementPlugin(),
27 | new webpack.NoEmitOnErrorsPlugin(),
28 | // https://github.com/ampedandwired/html-webpack-plugin
29 | new HtmlWebpackPlugin({
30 | filename: 'index.html',
31 | template: 'index.html',
32 | inject: true
33 | }),
34 | new FriendlyErrorsPlugin()
35 | ]
36 | })
37 |
--------------------------------------------------------------------------------
/build/webpack.prod.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const utils = require('./utils')
4 | const webpack = require('webpack')
5 | const config = require('../config')
6 | const merge = require('webpack-merge')
7 | const baseWebpackConfig = require('./webpack.base.conf')
8 | const CopyWebpackPlugin = require('copy-webpack-plugin')
9 | const HtmlWebpackPlugin = require('html-webpack-plugin')
10 | const ExtractTextPlugin = require('extract-text-webpack-plugin')
11 | const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
12 |
13 | const env = config.build.env
14 |
15 | const webpackConfig = merge(baseWebpackConfig, {
16 | module: {
17 | rules: utils.styleLoaders({
18 | sourceMap: config.build.productionSourceMap,
19 | extract: true
20 | })
21 | },
22 | devtool: config.build.productionSourceMap ? '#source-map' : false,
23 | output: {
24 | path: config.build.assetsRoot,
25 | filename: utils.assetsPath('js/[name].[chunkhash].js'),
26 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
27 | },
28 | plugins: [
29 | // http://vuejs.github.io/vue-loader/en/workflow/production.html
30 | new webpack.DefinePlugin({
31 | 'process.env': env
32 | }),
33 | // UglifyJs do not support ES6+, you can also use babel-minify for better treeshaking: https://github.com/babel/minify
34 | new webpack.optimize.UglifyJsPlugin({
35 | compress: {
36 | warnings: false
37 | },
38 | sourceMap: true
39 | }),
40 | // extract css into its own file
41 | new ExtractTextPlugin({
42 | filename: utils.assetsPath('css/[name].[contenthash].css')
43 | }),
44 | // Compress extracted CSS. We are using this plugin so that possible
45 | // duplicated CSS from different components can be deduped.
46 | new OptimizeCSSPlugin({
47 | cssProcessorOptions: {
48 | safe: true
49 | }
50 | }),
51 | // generate dist index.html with correct asset hash for caching.
52 | // you can customize output by editing /index.html
53 | // see https://github.com/ampedandwired/html-webpack-plugin
54 | new HtmlWebpackPlugin({
55 | filename: config.build.index,
56 | template: 'index.html',
57 | inject: true,
58 | minify: {
59 | removeComments: true,
60 | collapseWhitespace: true,
61 | removeAttributeQuotes: true
62 | // more options:
63 | // https://github.com/kangax/html-minifier#options-quick-reference
64 | },
65 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin
66 | chunksSortMode: 'dependency'
67 | }),
68 | // keep module.id stable when vender modules does not change
69 | new webpack.HashedModuleIdsPlugin(),
70 | // split vendor js into its own file
71 | new webpack.optimize.CommonsChunkPlugin({
72 | name: 'vendor',
73 | minChunks: function (module) {
74 | // any required modules inside node_modules are extracted to vendor
75 | return (
76 | module.resource &&
77 | /\.js$/.test(module.resource) &&
78 | module.resource.indexOf(
79 | path.join(__dirname, '../node_modules')
80 | ) === 0
81 | )
82 | }
83 | }),
84 | // extract webpack runtime and module manifest to its own file in order to
85 | // prevent vendor hash from being updated whenever app bundle is updated
86 | new webpack.optimize.CommonsChunkPlugin({
87 | name: 'manifest',
88 | chunks: ['vendor']
89 | }),
90 | // copy custom static assets
91 | new CopyWebpackPlugin([
92 | {
93 | from: path.resolve(__dirname, '../static'),
94 | to: config.build.assetsSubDirectory,
95 | ignore: ['.*']
96 | }
97 | ])
98 | ]
99 | })
100 |
101 | if (config.build.productionGzip) {
102 | const CompressionWebpackPlugin = require('compression-webpack-plugin')
103 |
104 | webpackConfig.plugins.push(
105 | new CompressionWebpackPlugin({
106 | asset: '[path].gz[query]',
107 | algorithm: 'gzip',
108 | test: new RegExp(
109 | '\\.(' +
110 | config.build.productionGzipExtensions.join('|') +
111 | ')$'
112 | ),
113 | threshold: 10240,
114 | minRatio: 0.8
115 | })
116 | )
117 | }
118 |
119 | if (config.build.bundleAnalyzerReport) {
120 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
121 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
122 | }
123 |
124 | module.exports = webpackConfig
125 |
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const merge = require('webpack-merge')
3 | const prodEnv = require('./prod.env')
4 |
5 | module.exports = merge(prodEnv, {
6 | NODE_ENV: '"development"'
7 | })
8 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 |
2 | 'use strict'
3 | // Template version: 1.1.3
4 | // see http://vuejs-templates.github.io/webpack for documentation.
5 |
6 | const path = require('path')
7 |
8 | module.exports = {
9 | build: {
10 | env: require('./prod.env'),
11 | index: path.resolve(__dirname, '../dist/index.html'),
12 | assetsRoot: path.resolve(__dirname, '../dist'),
13 | assetsSubDirectory: 'static',
14 | assetsPublicPath: '/',
15 | productionSourceMap: true,
16 | // Gzip off by default as many popular static hosts such as
17 | // Surge or Netlify already gzip all static assets for you.
18 | // Before setting to `true`, make sure to:
19 | // npm install --save-dev compression-webpack-plugin
20 | productionGzip: false,
21 | productionGzipExtensions: ['js', 'css'],
22 | // Run the build command with an extra argument to
23 | // View the bundle analyzer report after build finishes:
24 | // `npm run build --report`
25 | // Set to `true` or `false` to always turn it on or off
26 | bundleAnalyzerReport: process.env.npm_config_report
27 | },
28 | dev: {
29 | env: require('./dev.env'),
30 | port: process.env.PORT || 8080,
31 | autoOpenBrowser: true,
32 | assetsSubDirectory: 'static',
33 | assetsPublicPath: '/',
34 | proxyTable: {},
35 | // CSS Sourcemaps off by default because relative paths are "buggy"
36 | // with this option, according to the CSS-Loader README
37 | // (https://github.com/webpack/css-loader#sourcemaps)
38 | // In our experience, they generally work as expected,
39 | // just be aware of this issue when enabling this option.
40 | cssSourceMap: false
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | module.exports = {
3 | NODE_ENV: '"production"'
4 | }
5 |
--------------------------------------------------------------------------------
/docs/structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/igeligel/vuex-simple-structure/70a9a223cadb8273ae485b3315b03e7ef9231c34/docs/structure.png
--------------------------------------------------------------------------------
/docs/structure.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
22 |
23 |
24 |
25 |
26 |
27 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Page-1
39 |
41 |
42 |
43 | Rectangle
44 | store
45 |
46 |
47 |
48 |
49 |
50 |
52 |
53 |
54 |
55 | store
56 |
57 | Rectangle.3
58 | modules
59 |
60 |
61 |
62 |
63 |
64 |
66 |
67 |
68 |
69 | modules
70 |
71 | Rounded Rectangle
72 | index.js
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
95 |
98 |
99 |
102 | index.js
103 |
104 | Rounded Rectangle.5
105 | products.js
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
128 |
131 |
132 |
135 | products.js
136 |
137 | Rounded Rectangle.6
138 | chat.js
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
161 |
164 |
165 |
168 | chat.js
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 | Dependency
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 | Dependency.12
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 | Dependency.17
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 | Association
256 |
257 |
258 |
259 |
260 |
261 |
262 |
--------------------------------------------------------------------------------
/docs/structure.vsdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/igeligel/vuex-simple-structure/70a9a223cadb8273ae485b3315b03e7ef9231c34/docs/structure.vsdx
--------------------------------------------------------------------------------
/docs/vs-code-folder-structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/igeligel/vuex-simple-structure/70a9a223cadb8273ae485b3315b03e7ef9231c34/docs/vs-code-folder-structure.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | vuex-simple-structure
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": {
3 | "email": "kevinigeligeligel+vuexsimple@gmail.com",
4 | "name": "Kevin Peters",
5 | "url": "https://www.kevinpeters.net/"
6 | },
7 | "browserslist": [
8 | "> 1%",
9 | "last 2 versions",
10 | "not ie <= 8"
11 | ],
12 | "bugs": {
13 | "url": "https://github.com/igeligel/vuex-simple-structure/issues"
14 | },
15 | "dependencies": {
16 | "vue": "^2.5.16",
17 | "vue-router": "^3.0.1",
18 | "vuex": "^3.0.1"
19 | },
20 | "description": "A Vue.js showcasing Vuex capabilities in a simple example",
21 | "devDependencies": {
22 | "autoprefixer": "^8.5.1",
23 | "babel-core": "^6.26.3",
24 | "babel-eslint": "^8.2.3",
25 | "babel-loader": "^7.1.4",
26 | "babel-plugin-transform-runtime": "^6.23.0",
27 | "babel-preset-env": "^1.7.0",
28 | "babel-preset-stage-2": "^6.24.1",
29 | "babel-register": "^6.26.0",
30 | "chalk": "^2.4.1",
31 | "connect-history-api-fallback": "^1.5.0",
32 | "copy-webpack-plugin": "^4.5.1",
33 | "css-loader": "^0.28.11",
34 | "eslint": "^4.19.1",
35 | "eslint-config-airbnb-base": "^12.1.0",
36 | "eslint-friendly-formatter": "^4.0.1",
37 | "eslint-import-resolver-webpack": "^0.10.0",
38 | "eslint-loader": "^2.0.0",
39 | "eslint-plugin-html": "^4.0.3",
40 | "eslint-plugin-import": "^2.12.0",
41 | "eventsource-polyfill": "^0.9.6",
42 | "express": "^4.16.3",
43 | "extract-text-webpack-plugin": "^3.0.2",
44 | "file-loader": "^1.1.11",
45 | "friendly-errors-webpack-plugin": "^1.7.0",
46 | "html-webpack-plugin": "^3.2.0",
47 | "http-proxy-middleware": "^0.18.0",
48 | "node-sass": "^4.9.0",
49 | "opn": "^5.3.0",
50 | "optimize-css-assets-webpack-plugin": "^3.2.0",
51 | "ora": "^2.1.0",
52 | "portfinder": "^1.0.13",
53 | "rimraf": "^2.6.2",
54 | "sass-loader": "^7.0.1",
55 | "semver": "^5.5.0",
56 | "shelljs": "^0.8.2",
57 | "url-loader": "^1.0.1",
58 | "vue-loader": "^15.2.2",
59 | "vue-style-loader": "^4.1.0",
60 | "vue-template-compiler": "^2.5.16",
61 | "webpack": "^3.12.0",
62 | "webpack-bundle-analyzer": "^2.13.1",
63 | "webpack-dev-middleware": "^2.0.6",
64 | "webpack-hot-middleware": "^2.22.2",
65 | "webpack-merge": "^4.1.2"
66 | },
67 | "engines": {
68 | "node": ">= 4.0.0",
69 | "npm": ">= 3.0.0"
70 | },
71 | "homepage": "https://vuex-simple-structure.netlify.com/",
72 | "keywords": [
73 | "vuex",
74 | "simple",
75 | "vuejs",
76 | "example"
77 | ],
78 | "license": "MIT",
79 | "name": "vuex-simple-structure",
80 | "repository": {
81 | "type": "git",
82 | "url": "https://github.com/igeligel/vuex-simple-structure"
83 | },
84 | "scripts": {
85 | "build": "node build/build.js",
86 | "dev": "node build/dev-server.js",
87 | "lint": "eslint --ext .js,.vue src",
88 | "start": "npm run dev"
89 | },
90 | "version": "1.0.0"
91 | }
92 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
20 |
--------------------------------------------------------------------------------
/src/api/index.js:
--------------------------------------------------------------------------------
1 | const fetchMessages = new Promise((resolve) => {
2 | setTimeout(() => {
3 | resolve([
4 | {
5 | id: 'message-a7fe282a-bcb3-47a6-b746-e5f41fc2ea66',
6 | author: 'Robert',
7 | content: 'This is an awesome architecture',
8 | time: '2017-10-21T09:46:19+00:00',
9 | points: 5,
10 | reactions: [],
11 | },
12 | {
13 | id: 'message-192a2e4d-1203-49b9-bd39-09710e6075e5',
14 | author: 'Anna',
15 | content: 'Yeah i agree',
16 | time: '2017-10-21T09:46:25+00:00',
17 | points: 0,
18 | reactions: [],
19 | },
20 | ]);
21 | }, 500);
22 | });
23 |
24 | const fetchProducts = new Promise((resolve) => {
25 | setTimeout(() => {
26 | resolve([
27 | {
28 | id: 'product-18b9a98e-812d-4627-95e0-994245a137ee',
29 | type: 'shoe',
30 | brand: 'adidas Originals',
31 | model: 'PW TENNIS HU - Sneaker low',
32 | },
33 | {
34 | id: 'product-4eaf41ba-0632-4d51-9a11-7921ea819e0f',
35 | type: 'shoe',
36 | brand: 'Vans',
37 | model: 'OLD SKOOL - skate shoe',
38 | },
39 | {
40 | id: 'product-cc2bfba2-207e-49ba-b942-3c79c24d6665',
41 | type: 'shoe',
42 | brand: 'adidas Originals',
43 | model: 'TUBULAR SHADOW - Sneaker low',
44 | },
45 | {
46 | id: 'product-5ccca7c3-2bef-4c9e-bb4a-cffc2534b217',
47 | type: 'shoe',
48 | brand: 'Nike SB',
49 | model: 'STEFAN JANOSKI MAX - Sneaker low',
50 | },
51 | ]);
52 | }, 750);
53 | });
54 |
55 | export { fetchMessages, fetchProducts };
56 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/igeligel/vuex-simple-structure/70a9a223cadb8273ae485b3315b03e7ef9231c34/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/components/ChatList.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
26 |
--------------------------------------------------------------------------------
/src/components/ChatListElement.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | [{{timeRepresentation}}]
4 | {{message.author}}:
5 |
6 |
7 |
8 |
9 |
24 |
25 |
30 |
--------------------------------------------------------------------------------
/src/components/ProductList.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Type
5 | Brand
6 | Model
7 |
8 |
13 |
14 | No Products given
15 |
16 |
17 |
18 |
19 |
34 |
35 |
46 |
47 |
--------------------------------------------------------------------------------
/src/components/ProductListElement.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | // The Vue build version to load with the `import` command
2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3 | import Vue from 'vue';
4 | import App from './App';
5 | import router from './router';
6 | import store from './store';
7 |
8 | Vue.config.productionTip = false;
9 |
10 | /* eslint-disable no-new */
11 | new Vue({
12 | el: '#app',
13 | router,
14 | store,
15 | template: ' ',
16 | components: { App },
17 | });
18 |
--------------------------------------------------------------------------------
/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Router from 'vue-router';
3 | import HomeView from '@/views/Home';
4 |
5 | Vue.use(Router);
6 |
7 | export default new Router({
8 | routes: [
9 | {
10 | path: '/',
11 | name: 'Home',
12 | component: HomeView,
13 | },
14 | ],
15 | });
16 |
--------------------------------------------------------------------------------
/src/store/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Vuex from 'vuex';
3 | import chatModule from './modules/chat';
4 | import productsModule from './modules/products';
5 |
6 | Vue.use(Vuex);
7 |
8 | export default new Vuex.Store({
9 | modules: {
10 | chat: chatModule,
11 | products: productsModule,
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/src/store/modules/chat.js:
--------------------------------------------------------------------------------
1 | import { fetchMessages } from '@/api';
2 |
3 | const defaultState = {
4 | messages: [],
5 | };
6 |
7 | const actions = {
8 | getMessages: (context) => {
9 | fetchMessages
10 | .then((response) => {
11 | context.commit('MESSAGES_UPDATED', response);
12 | })
13 | .catch((error) => {
14 | // eslint-disable-next-line
15 | console.error(error);
16 | });
17 | },
18 | };
19 |
20 | const mutations = {
21 | MESSAGES_UPDATED: (state, messages) => {
22 | state.messages = messages;
23 | },
24 | };
25 |
26 | const getters = {
27 | messages: state => state.messages,
28 | };
29 |
30 | export default {
31 | state: defaultState,
32 | getters,
33 | actions,
34 | mutations,
35 | };
36 |
--------------------------------------------------------------------------------
/src/store/modules/products.js:
--------------------------------------------------------------------------------
1 | import { fetchProducts } from '@/api';
2 |
3 | const defaultState = {
4 | products: [],
5 | };
6 |
7 | const actions = {
8 | getProducts: (context) => {
9 | fetchProducts
10 | .then((response) => {
11 | context.commit('PRODUCTS_UPDATED', response);
12 | })
13 | .catch((error) => {
14 | // eslint-disable-next-line
15 | console.error(error);
16 | });
17 | },
18 | };
19 |
20 | const mutations = {
21 | PRODUCTS_UPDATED: (state, products) => {
22 | state.products = products;
23 | },
24 | };
25 |
26 | const getters = {
27 | products: state => state.products,
28 | };
29 |
30 | export default {
31 | state: defaultState,
32 | getters,
33 | actions,
34 | mutations,
35 | };
36 |
--------------------------------------------------------------------------------
/src/util/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/igeligel/vuex-simple-structure/70a9a223cadb8273ae485b3315b03e7ef9231c34/src/util/.gitkeep
--------------------------------------------------------------------------------
/src/views/Home.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
32 |
33 |
43 |
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/igeligel/vuex-simple-structure/70a9a223cadb8273ae485b3315b03e7ef9231c34/static/.gitkeep
--------------------------------------------------------------------------------