加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

vue-cli + webpack自动生成项目

发布时间:2020-12-14 23:58:44 所属栏目:资源 来源:网络整理
导读:div class="cnblogs_code" # 全局安装 vue- -- vue- 创建过程参考:https://www.2cto.com/kf/201711/695061.html,单元测试选择的是jest 创建好的项目结构如下: 下面就重点分析build和config目录下各个配置文件的解析: config目录下的各项配置都是为了服务

<div class="cnblogs_code">

# 全局安装 vue--- vue-

创建过程参考:https://www.2cto.com/kf/201711/695061.html,单元测试选择的是jest

创建好的项目结构如下:

下面就重点分析build和config目录下各个配置文件的解析:

config目录下的各项配置都是为了服务webpack的配置,给不同的编译条件提供配置

config/index.js

<span style="color: #0000ff">const path = require(<span style="color: #800000">'<span style="color: #800000">path<span style="color: #800000">'<span style="color: #000000">)

module.exports =<span style="color: #000000"> {
dev: {

</span><span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; Paths</span>
assetsSubDirectory: <span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;static</span><span style="color: #800000"&gt;'</span><span style="color: #000000"&gt;,assetsPublicPath: </span><span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;/</span><span style="color: #800000"&gt;'</span><span style="color: #000000"&gt;,proxyTable: {},</span><span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; Various Dev Server settings</span>
host: <span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;localhost</span><span style="color: #800000"&gt;'</span>,<span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; can be overwritten by process.env.HOST</span>
port: <span style="color: #800080"&gt;8080</span>,<span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; can be overwritten by process.env.PORT,if port is in use,a free one will be determined</span>
autoOpenBrowser: <span style="color: #0000ff"&gt;false</span><span style="color: #000000"&gt;,errorOverlay: </span><span style="color: #0000ff"&gt;true</span><span style="color: #000000"&gt;,notifyOnErrors: </span><span style="color: #0000ff"&gt;true</span><span style="color: #000000"&gt;,poll: </span><span style="color: #0000ff"&gt;false</span><span style="color: #000000"&gt;,useEslint: </span><span style="color: #0000ff"&gt;true</span><span style="color: #000000"&gt;,showEslintErrorsInOverlay: </span><span style="color: #0000ff"&gt;false</span><span style="color: #000000"&gt;,</span><span style="color: #008000"&gt;/*</span><span style="color: #008000"&gt;*
 * Source Maps
 </span><span style="color: #008000"&gt;*/</span>

<span style="color: #008000"&gt;//</span> <span style="color: #008000; text-decoration: underline"&gt;https://webpack.js.org/configuration/devtool/</span><span style="color: #008000"&gt;#development</span>
devtool: <span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;cheap-module-eval-source-map</span><span style="color: #800000"&gt;'</span><span style="color: #000000"&gt;,cacheBusting: </span><span style="color: #0000ff"&gt;true</span><span style="color: #000000"&gt;,cssSourceMap: </span><span style="color: #0000ff"&gt;true</span><span style="color: #000000"&gt;

},build: {
<span style="color: #008000">//<span style="color: #008000"> 在任何模块文件内部,可以使用dirname变量获取当前模块文件所在目录的完整绝对路径。
index: path.resolve(
dirname,<span style="color: #800000">'<span style="color: #800000">../dist/index.html<span style="color: #800000">'<span style="color: #000000">),<span style="color: #008000">//<span style="color: #008000"> Paths
assetsRoot: path.resolve(__dirname,<span style="color: #800000">'<span style="color: #800000">../dist<span style="color: #800000">'<span style="color: #000000">),assetsSubDirectory: <span style="color: #800000">'<span style="color: #800000">static<span style="color: #800000">'<span style="color: #000000">,<span style="color: #008000">/<span style="color: #008000">

  • Source Maps
    <span style="color: #008000">*/<span style="color: #000000">
productionSourceMap: </span><span style="color: #0000ff"&gt;true</span><span style="color: #000000"&gt;,</span><span style="color: #008000"&gt;//</span> <span style="color: #008000; text-decoration: underline"&gt;https://webpack.js.org/configuration/devtool/</span><span style="color: #008000"&gt;#production</span>
devtool: <span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;#source-map</span><span style="color: #800000"&gt;'</span><span style="color: #000000"&gt;,productionGzip: </span><span style="color: #0000ff"&gt;false</span><span style="color: #000000"&gt;,productionGzipExtensions: [</span><span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;js</span><span style="color: #800000"&gt;'</span>,<span style="color: #800000"&gt;'</span><span style="color: #800000"&gt;css</span><span style="color: #800000"&gt;'</span><span style="color: #000000"&gt;],</span><span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; Run the build command with an extra argument to
</span><span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; View the bundle analyzer report after build finishes:
</span><span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; `npm run build --report`
</span><span style="color: #008000"&gt;//</span><span style="color: #008000"&gt; Set to `true` or `false` to always turn it on or off</span>

<span style="color: #000000"> bundleAnalyzerReport: process.env.npm_config_report
}
}

详解:http://www.cnblogs.com/whkl-m/p/6627864.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读