vue-loader

how to extract vue files style into one seperate style.css file

感情迁移 提交于 2020-01-13 18:58:20
问题 I'm using vue-loader and by default for each vue files you have one style tag in your view which is not a good thing, according to vue-loader documentation i can do this https://vue-loader.vuejs.org/en/configurations/extract-css.html my webpack-config.js file var path = require('path') var webpack = require('webpack') const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, './dist'), publicPath: '

简述--webpack搭建Vue项目基本结构

眉间皱痕 提交于 2020-01-11 00:44:28
简述–webpack搭建Vue项目基本结构 文章目录 简述--webpack搭建Vue项目基本结构 1. 初始化项目 2. 安装webpack、webpack-cli 3. 搭建基本的目录结构 4. 配置webpack.config.js文件 5. webpack-dev-server 6. html-webpack-plugin 7. css-loader、style-loader、less-loader 8. url-loader、html-loader 9. babel-loader 10. vue-loader npm -D -S 的区别: -D: 同 --save-dev,开发环境 -S: 同–save,生产环境 之前的博客 ** 1. 初始化项目 npm init 2. 安装webpack、webpack-cli npm i webpack webpack-cli -D 3. 搭建基本的目录结构 vue文件会在最后的时候进行处理,前期只进行基本功能的搭建,如果需要看后续步骤,前边的您可以直接跳过。 4. 配置webpack.config.js文件 const path = require ( 'path' ) ; module . exports = { // 定义打包的入口 entry : { bundle : path . join ( __dirname ,

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your w ebpack config.

蓝咒 提交于 2020-01-06 20:38:14
Vue Loader v15 现在需要配合一个 webpack 插件 VueLoaderPlugin 才能正确使用 // webpack.config.js const VueLoaderPlugin = require('vue-loader/lib/plugin') module.exports = { // ... plugins: [ new VueLoaderPlugin() ] } 官方文档: https://vue-loader.vuejs.org/zh/migrating.html 来源: https://www.cnblogs.com/nili/p/12155859.html

Vue SFC styles not being extracted in webpack production build

蓝咒 提交于 2020-01-06 05:35:30
问题 Trying to add vue (and SFCs) to my webpack app. The <template> and <script> blocks work fine, but for some reason the styles in the <style> block are not being extracted for production build. In the dev build, it's extracting the .vue <style> block to a separate css file (named for the entrypoint). Which is OK but I'd prefer they went into my main stylesheet. But no matter what I try, I can't get any .vue styles to show up (in any file) for the production build. This is an abbreviated version

Vue知识点精简汇总

浪子不回头ぞ 提交于 2020-01-04 00:59:17
一、 组件component 1. 什么是组件? 组件(Component)是 Vue.js 最强大的功能之一。组件可以扩展 HTML 元素,封装可重用的代码 组件是自定义元素(对象) 2. 定义组件的方式 方式1:先创建组件构造器,然后由组件构造器创建组件 方式2:直接创建组件 3. 组件的分类 分类:全局组件、局部组件 4. 引用模板 将组件内容放到模板<template>中并引用 5. 动态组件 <component :is="">组件 多个组件使用同一个挂载点,然后动态的在它们之间切换 <keep-alive>组件 二、 组件间数据传递 1. 父子组件 在一个组件内部定义另一个组件,称为父子组件 子组件只能在父组件内部使用 默认情况下,子组件无法访问父组件中的数据,每个组件实例的作用域是独立的 2. 组件间数据传递 (通信) 2.1 子组件访问父组件的数据 a)在调用子组件时,绑定想要获取的父组件中的数据 b)在子组件内部,使用props选项声明获取的数据,即接收来自父组件的数据 总结:父组件通过props向下传递数据给子组件 注:组件中的数据共有三种形式:data、props、computed 2.2 父组件访问子组件的数据 a)在子组件中使用vm.$emit(事件名,数据)触发一个自定义事件,事件名自定义 b)父组件在使用子组件的地方监听子组件触发的事件

Does import create a new copy of imported library?

风流意气都作罢 提交于 2020-01-01 10:12:03
问题 I'm using webpack + vue-loader to create vuejs app. I have multiple .vue files for components. When I write something like this: import _ from 'lodash' inside the script part of ComponentA.vue and ComponentB.vue , does this create two separate copies of lodash or does it simply import a reference? 回答1: Importing an ES6 module, or any part of an ES6 module, produces a binding . CommonJS modules export values, while ES6 modules export immutable bindings . This blog post explains what that means

Scope Bootstrap Css in Vue

感情迁移 提交于 2019-12-30 03:10:11
问题 I'm trying to use Bootstrap in a Vue component, and I want all CSS to be scoped. I tried something like this: <style scoped> @import "~bootstrap/dist/css/bootstrap.css"; @import "~bootstrap-vue/dist/bootstrap-vue.css"; </style> But it doesn't seem like the css is scoped. Is there any way to do that? 回答1: <style scoped src="~bootstrap/dist/css/bootstrap.css"></style> <style scoped src="~bootstrap-vue/dist/bootstrap-vue.css"></style> Update : a hack using SCSS Reason why the first solution won

Vux配置

随声附和 提交于 2019-12-26 02:02:29
详细使用方法翻阅官网: https://vux.li/ 配置vux:   在网上搜了会,发现几乎都是vue-cli旧版的配置方法,有一些已经不能用了,在这里整理下正确的配置方法   安装各插件   1、在项目里面安装vux npm install vux --save   2、安装vux-loader(必须安装) npm install vux-loader --save-dev   3、安装less-loader(这个是用以正确编译less源码,否则会出现 ' Cannot GET / ') npm install less less-loader --save-dev   4、安装yaml-loader (以正确进行语言文件读取) npm install yaml-loader --save-dev 配置vux环境:   这里注意由于vue-cli3使用的是webpack4而且更新过vue-loader,所以vux使用起来会存在一些兼容的问题,这里需要额外配置一下。   官方更新过vue/cli3.x 的vue-loader,正常配置会导致加载错误。所以需要手动指定vue-loader的版本来解决加载问题。 yarn add vue-loader@14.2.2 -D or npm install vue-loader@14.2.2 -D

Path to static assets in vue.js application

不想你离开。 提交于 2019-12-24 00:37:57
问题 I am developing a single page application based on the vue-cli webpack template. Since we have to use static assets as well, we need to reference them in our stylesheet. The official documentation recommends to use an absolute path like the following one: background-image: url('/assets/images/lo/example2.svg'); The problem is, that static assets won't be processed by the vue-loader and webpack itself, so the urls won't be set correctly in the final output stylesheet. All assets that will be

Webpack with babel-loader not emitting valid es5

被刻印的时光 ゝ 提交于 2019-12-23 05:43:05
问题 I have a webpack config that is based off https://github.com/vuejs-templates/webpack-simple/blob/master/template/webpack.config.js It uses vue-loader and babel-loader. The issue is I cannot get it to generate ES5 code so that it will work in the most broad range of clients. If I use the ES2015 preset, webpack.optimize.UglifyJsPlugin fails to minify the output because Uglify can only handle ES5 (not counting the harmony branch). The errors are similar to: Unexpected token: punc (() and occur