目录/文件 | 说明 | 详解 |
---|---|---|
build | 项目构建(webpack)相关代码 | 详解 |
config | 配置目录,包括端口号等 | 详解 |
node_modules | npm 加载的项目依赖模块 | 详解 |
src | 这里是咱们要开发的目录,基本上要作的事情都在这个目录里。里面包含了几个目录及文件: ♞ assets:放置一些图片,如 logo ♞ components:放置一些组件 ♞ views:页面(视图)组件 ♞ router.js:路由脚本文件 ♞ App.vue:项目入口文件 ♞ main.js::项目的核心文件 |
详解 |
static | 静态资源目录,如图片、字体等 | 详解 |
test | 初始测试目录,可删除 | 详解 |
.xxxx 文件 | 这些是一些配置文件,包括语法配置,git 配置等 | |
index.html | 首页入口文件 | |
package.json | 项目配置文件 | 详解 |
README.md | 项目的说明文档,markdown 格式 |
目录/文件 | 说明 |
---|---|
dev.env.js | 开发环境配置 |
index.js | 主要配置 |
prod.env.js | 生产环境配置 |
test.env.js | 测试环境配置 |
'use strict' // Template version: 1.3.1 // see http://vuejs-templates.github.io/webpack for documentation. // 引入 node.js 的路径模块 const path = require('path') module.exports = { dev: { // Paths assetsSubDirectory: 'static', assetsPublicPath: '/', // 建一个虚拟 api 服务器用来代理本机的请求,只能用于开发模式 proxyTable: {}, // 服务 host host: 'localhost', // 服务端口号 port: 8080, // 自动打开浏览器浏览器 autoOpenBrowser: false, errorOverlay: true, notifyOnErrors: true, poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- // Use Eslint Loader? // If true, your code will be linted during bundling and // linting errors and warnings will be shown in the console. useEslint: true, // If true, eslint errors and warnings will also be shown in the error overlay // in the browser. showEslintErrorsInOverlay: false, /** * Source Maps */ // https://webpack.js.org/configuration/devtool/#development devtool: 'cheap-module-eval-source-map', // If you have problems debugging vue-files in devtools, // set this to false - it *may* help // https://vue-loader.vuejs.org/en/options.html#cachebusting cacheBusting: true, cssSourceMap: true }, build: { // 下面是相对路径的拼接,假如当前跟目录是 config,那么下面配置的 index 属性的属性值就是 dist/index.html index: path.resolve(__dirname, '../dist/index.html'), // 定义的是静态资源的根目录 也就是 dist 目录 assetsRoot: path.resolve(__dirname, '../dist'), // 定义的是静态资源根目录的子目录 static,也就是 dist 目录下面的 static assetsSubDirectory: 'static', // 定义的是静态资源的公开路径,也就是真正的引用路径 assetsPublicPath: '/', /** * Source Maps */ productionSourceMap: true, // https://webpack.js.org/configuration/devtool/#production devtool: '#source-map', // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. // Before setting to `true`, make sure to: // npm install --save-dev compression-webpack-plugin // 是否压缩代码 productionGzip: false, // 定义要压缩哪些类型的文件 productionGzipExtensions: ['js', 'css'], // Run the build command with an extra argument to // View the bundle analyzer report after build finishes: // `npm run build --report` // Set to `true` or `false` to always turn it on or off // 编译完成后的报告,能够经过设置值为 true 和 false 来开启或关闭 bundleAnalyzerReport: process.env.npm_config_report } }
'use strict' // 配置文件合并模块 const merge = require('webpack-merge') // 导入 prod.env.js 配置文件 const prodEnv = require('./prod.env') module.exports = merge(prodEnv, { // 导出一个对象,NODE_ENV 是一个环境变量,指定 development 环境 NODE_ENV: '"development"' })
'use strict' module.exports = { // 导出一个对象,NODE_ENV 是一个环境变量,指定 production 环境 NODE_ENV: '"production"' }
'use strict' // 配置文件合并模块 const merge = require('webpack-merge') // 导入 dev.env.js 配置文件 const devEnv = require('./dev.env') module.exports = merge(devEnv, { // 导出一个对象,NODE_ENV 是一个环境变量,指定 testing 环境 NODE_ENV: '"testing"' })