├── .babelrc
├── src
├── assets
│ └── logo.png
├── HomeButton.vue
├── LocateButton.vue
├── App.vue
└── main.js
├── .gitignore
├── .editorconfig
├── index.html
├── README.md
├── package.json
└── webpack.config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", { "modules": false }],
4 | "stage-3"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomwayson/esri-vue-cli-example/HEAD/src/assets/logo.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log
5 | yarn-error.log
6 |
7 | # Editor directories and files
8 | .idea
9 | *.suo
10 | *.ntvs*
11 | *.njsproj
12 | *.sln
13 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | esri-vue-cli-example
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # esri-vue-cli-example
2 |
3 | An example of how to use the [ArcGIS API for JavaScript 3.x](https://developers.arcgis.com/javascript/3/) in a [vue-cli](https://github.com/vuejs/vue-cli) application (via [esri-loader](https://github.com/Esri/esri-loader)).
4 |
5 | If you're interested in seeing [v4x](https://developers.arcgis.com/javascript/) in a [NUXT](https://nuxtjs.org/) application, see [vue-jsapi4](https://github.com/odoe/vue-jsapi4).
6 |
7 | ## Build Setup
8 |
9 | ``` bash
10 | # install dependencies
11 | npm install
12 |
13 | # serve with hot reload at localhost:8080
14 | npm run dev
15 |
16 | # build for production with minification
17 | npm run build
18 | ```
19 |
20 | For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
21 |
--------------------------------------------------------------------------------
/src/HomeButton.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
35 |
36 |
47 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "esri-vue-cli-example",
3 | "description": "An example of how to use the ArcGIS API for JavaScript 3.x in a vue-cli application",
4 | "version": "1.0.0",
5 | "author": "Tom Wayson ",
6 | "license": "Apache-2.0",
7 | "private": true,
8 | "scripts": {
9 | "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
10 | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
11 | },
12 | "dependencies": {
13 | "esri-loader": "^2.0.0",
14 | "vue": "^2.5.11",
15 | "vue-router": "^3.0.1"
16 | },
17 | "browserslist": [
18 | "> 1%",
19 | "last 2 versions",
20 | "not ie <= 8"
21 | ],
22 | "devDependencies": {
23 | "babel-core": "^6.26.0",
24 | "babel-loader": "^7.1.2",
25 | "babel-preset-env": "^1.6.0",
26 | "babel-preset-stage-3": "^6.24.1",
27 | "cross-env": "^5.0.5",
28 | "css-loader": "^0.28.7",
29 | "file-loader": "^1.1.4",
30 | "vue-loader": "^13.0.5",
31 | "vue-template-compiler": "^2.4.4",
32 | "webpack": "^3.6.0",
33 | "webpack-dev-server": "^2.9.1"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/LocateButton.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
35 |
36 |
47 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |

4 |
{{ msg }}
5 |
6 | - Home Button
7 | - Locate Button
8 |
9 |
10 |
11 |
12 |
13 |
23 |
24 |
55 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueRouter from 'vue-router'
3 | import { loadScript } from 'esri-loader'
4 | import App from './App.vue'
5 | import HomeButton from './HomeButton.vue'
6 | import LocateButton from './LocateButton.vue'
7 |
8 | Vue.use(VueRouter)
9 |
10 | // 2. Define some routes
11 | // Each route should map to a component. The "component" can
12 | // either be an actual component constructor created via
13 | // `Vue.extend()`, or just a component options object.
14 | // We'll talk about nested routes later.
15 | const routes = [
16 | { path: '/home-button', component: HomeButton },
17 | { path: '/locate-button', component: LocateButton },
18 | ]
19 |
20 | // 3. Create the router instance and pass the `routes` option
21 | // You can pass in additional options here, but let's
22 | // keep it simple for now.
23 | const router = new VueRouter({
24 | routes // short for `routes: routes`
25 | })
26 |
27 | // preload the ArcGIS API
28 | const options = {
29 | url: 'https://js.arcgis.com/3.23/',
30 | };
31 | loadScript(options)
32 |
33 | // render the app
34 | new Vue({
35 | el: '#app',
36 | router,
37 | render: h => h(App)
38 | })
39 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var webpack = require('webpack')
3 |
4 | module.exports = {
5 | entry: './src/main.js',
6 | output: {
7 | path: path.resolve(__dirname, './dist'),
8 | publicPath: '/dist/',
9 | filename: 'build.js'
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.css$/,
15 | use: [
16 | 'vue-style-loader',
17 | 'css-loader'
18 | ],
19 | }, {
20 | test: /\.vue$/,
21 | loader: 'vue-loader',
22 | options: {
23 | loaders: {
24 | }
25 | // other vue-loader options go here
26 | }
27 | },
28 | {
29 | test: /\.js$/,
30 | loader: 'babel-loader',
31 | exclude: /node_modules/
32 | },
33 | {
34 | test: /\.(png|jpg|gif|svg)$/,
35 | loader: 'file-loader',
36 | options: {
37 | name: '[name].[ext]?[hash]'
38 | }
39 | }
40 | ]
41 | },
42 | resolve: {
43 | alias: {
44 | 'vue$': 'vue/dist/vue.esm.js'
45 | },
46 | extensions: ['*', '.js', '.vue', '.json']
47 | },
48 | devServer: {
49 | historyApiFallback: true,
50 | noInfo: true,
51 | overlay: true
52 | },
53 | performance: {
54 | hints: false
55 | },
56 | devtool: '#eval-source-map'
57 | }
58 |
59 | if (process.env.NODE_ENV === 'production') {
60 | module.exports.devtool = '#source-map'
61 | // http://vue-loader.vuejs.org/en/workflow/production.html
62 | module.exports.plugins = (module.exports.plugins || []).concat([
63 | new webpack.DefinePlugin({
64 | 'process.env': {
65 | NODE_ENV: '"production"'
66 | }
67 | }),
68 | new webpack.optimize.UglifyJsPlugin({
69 | sourceMap: true,
70 | compress: {
71 | warnings: false
72 | }
73 | }),
74 | new webpack.LoaderOptionsPlugin({
75 | minimize: true
76 | })
77 | ])
78 | }
79 |
--------------------------------------------------------------------------------