摘要:配置文件代码得到入口文件源文件目录目录如下每个文件夹下的文件都会打包文件夹为组件生成多个入口文件
配置文件代码
var path = require("path")
var webpack = require("webpack")
var glob = require("glob");
// 源文件目录
var sSystem = "src/";
// src目录如下
每个文件夹下的.js文件都会打包
components文件夹为组件
// 生成多个入口文件
function getEntry() {
</>复制代码
var entry = {};
var nLength = sSystem.length - 1;
var srcDirName = "./" + sSystem + "/**/*.js";
glob.sync(srcDirName).forEach(function (name) {
//name:./src/ovdream/basic/member/index/index.js
var n = name.slice(name.lastIndexOf(sSystem) + nLength, name.length - 3);
//n:/member/index/index
entry[n] = name;
});
return entry;
}
exportsmodule.exports = {
</>复制代码
entry: getEntry(),
output: {
path: path.resolve(__dirname, "./dist"),
publicPath: "/dist/",
filename: "[name].js"
},
module: {
rules: [
{
test: /.css$/,
use: [
"vue-style-loader",
"css-loader"
],
},
{
test: /.vue$/,
loader: "vue-loader",
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
}
// other vue-loader options go here
}
},
{
test: /.js$/,
loader: "babel-loader",
exclude: /node_modules/
},
{
test: /.(png|jpg|gif|svg)$/,
loader: "file-loader",
options: {
name: "[name].[ext]?[hash]"
}
}
]
},
resolve: {
alias: {
"vue$": "vue/dist/vue.esm.js"
},
extensions: ["*", ".js", ".vue", ".json"]
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: "#eval-source-map"
}
if (process.env.NODE_ENV === "production") {
</>复制代码
module.exports.devtool = "#source-map"
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: ""production""
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/108317.html
摘要:另外备注一部分参数的说明折叠有助于文档树中文本节点的空白区域对进行压缩默认默认按照不同文件的依赖关系来排序。敲黑板讲重点的当然目前这部分的文档在官网还不是很全,所以这里我们参考了印记中文的说明文档,指优化模块。 链接 写在前面 为什么要自己手写一个脚手架? 如何去思考遇到的问题? 正文 链接 原文链接 github whale-vue ——写在前面 1、为什么要自己手写...
摘要:注意此处获取的数据是更新后的数据,但是获取页面中的元素是更新之前的钩子函数说明组件已经更新,所以你现在可以执行依赖于的操作。钩子函数说明实例销毁 Vue -渐进式JavaScript框架 介绍 vue 中文网 vue github Vue.js 是一套构建用户界面(UI)的渐进式JavaScript框架 库和框架的区别 我们所说的前端框架与库的区别? Library 库,本质上是一...
容易混淆概念解析 读这篇文章理清下面概念 webpack 中那些最易混淆的 5 个知识点 1.module,chunk 和 bundle 的区别是什么?2.filename 和 chunkFilename 的区别 版本区别 webpack 2x entry output loaders file-loader:把文件输出到一个文件夹中,在代码中通过相对 URL 去引用输出的文件 url-lo...
摘要:简单项目脚手架地址使用技术栈需要学习的知识内容相当多,尤其是教程,官方脚手架虽然相当完整齐全,但是修改起来还是挺花时间,于是自己参照网上的资料和之前做过的项目用到的构建工具地去写了一个简单项目脚手架。 简单vue项目脚手架 github地址 使用技术栈 webpack(^2.6.1) webpack-dev-server(^2.4.5) vue(^2.3.3) vuex(^2.3.1...
阅读 1428·2021-09-22 10:02
阅读 2071·2021-09-08 09:35
阅读 4120·2021-08-12 13:29
阅读 2656·2019-08-30 15:55
阅读 2301·2019-08-30 15:53
阅读 2354·2019-08-29 17:13
阅读 2799·2019-08-29 16:31
阅读 2992·2019-08-29 12:24