vue-loader

Unexpected token: operator (>) from UglifyJs

做~自己de王妃 提交于 2019-12-01 03:13:31
I have 2 Vue-Cli webpack projects (ClientApp and Lib). Lib is my components library (shared with other projects) Problem When I build my project ClientApp npm run build , I have the following error: ERROR in static/js/app.d08a24ce0e8d0438ce68.js from UglifyJs Unexpected token: operator (>) [C:/.../Lib/src/tools/escape-key.js:3,0][static/js/app.d08a24ce0e8d0438ce68.js:17468,38] Questions It seems like the error comes from an arrow function in the file escape-key.js . This is ES6 syntax and UglifyJS can't parse this. Shouldn't Babel go first, before Uglify? Note that is works well with *.vue

Vue 2 component styles without Vue loader

非 Y 不嫁゛ 提交于 2019-12-01 02:18:08
问题 Considering that there is single file component (as shown in the guide), <style> .example { color: red; } </style> <template> <div class="example">hi</div> </template> How can the same thing be done without Vue loader in non-modular ES5/ES6 environment? Considering that the style is scoped, <style scoped> .example { color: red; } </style> Is there a way to implement scoped CSS in non-modular environment, too? If there's none, is there a way to implement it in modular environment (Webpack),

Unexpected token: operator (>) from UglifyJs

我的梦境 提交于 2019-11-30 22:38:09
问题 I have 2 Vue-Cli webpack projects (ClientApp and Lib). Lib is my components library (shared with other projects) Problem When I build my project ClientApp npm run build , I have the following error: ERROR in static/js/app.d08a24ce0e8d0438ce68.js from UglifyJs Unexpected token: operator (>) [C:/.../Lib/src/tools/escape-key.js:3,0][static/js/app.d08a24ce0e8d0438ce68.js:17468,38] Questions It seems like the error comes from an arrow function in the file escape-key.js . This is ES6 syntax and

[Vue warn]: Failed to mount component: template or render function not defined in Webpack 4

与世无争的帅哥 提交于 2019-11-30 17:29:49
问题 I started getting this error once I upgraded to Webpack and related dependencies to v4: [Vue warn]: Failed to mount component: template or render function not defined. Here's the relevant snippets of my package.json and webpack.config.js before and after: Before upgrade: package.json { "dependencies": { "vue": "^2.5.0", "vue-template-compiler": "^2.5.0" }, "devDependencies": { "babel-core": "^6.9.0", "babel-loader": "^6.2.4", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform

Scope Bootstrap Css in Vue

痴心易碎 提交于 2019-11-30 13:49:38
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? <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't work: With scoped, the parent component's styles will not leak into child components. If you want a

vue-loader 的深入用法

試著忘記壹切 提交于 2019-11-29 07:06:51
自定义文件组件类型 <template> 、 <script> 和 <style> style 可以指定预处理,scoped等 自定义模块 除了 三个基本模块以外,还可以添加自定义模块。 如果找到了一个自定义块,并且规则匹配成功会编译,否则默默不处理。 // webpack.config.js { module: { rules: [ { resourceQuery: /blockType=foo/, loader: 'loader-to-use' } ] } } // 如此配置,如果是webpack构建的项目,可以使用 // 如果是vue-cli项目,无法解析,需要改下配置 // vue.config.js module.exports = { // configureWebpack: (config) => { config.module.rules.push({ resourceQuery: /blockType=docs/, loader: require.resolve('./docs-loader.js') }) } } import Layer from './Layer.vue' 独立定义模块 <docs> 我是自定义模块,和style同级 </docs> template <p>{{docs}}</p> data () { docs: Layer.__docs }

Webpack Loader种类以及执行顺序

本秂侑毒 提交于 2019-11-27 18:30:21
  我们在用webpack构建项目的时候,有两种配置打包文件的方式: import或者require :a-loader!b-loader!.././static/dog.png(打包某一个文件) 配置webpack.config.js文件的module.rules(打包某一类的文件)   针对于以上的第二种方式我贴下我之前一篇博客中的配置 Vue动态注册异步组件(非同一个工程的组件) var path = require('path') var webpack = require('webpack') module.exports = { entry: process.NODE_ENV === 'development' ? './src/main.js' : './src/component/index.js', output: { path: path.resolve(__dirname, './dist'), publicPath: '/dist/', filename: 'async-component.js' }, module: { rules: [ { test: /\.css$/, use: [ 'vue-style-loader', 'css-loader' ], }, { test: /\.scss$/, use: [ 'vue-style-loader',

实习总结——vue运行时问题(npm run dev)

烈酒焚心 提交于 2019-11-27 15:50:30
运行时问题(npm run dev): 1,npm run dev报错: This dependency was not found: * !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-1d57e5ea","scoped":false,"hasInlineConfig":false}!stylus-loader?{"sourceMap":false}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./a.vue in ./src/components/a.vue To install it, you can run: npm install --save !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-1d57e5ea

vue.js: always load a settings.scss file in every vue style section

柔情痞子 提交于 2019-11-27 14:36:58
问题 I find myself repeating this same pattern in every .vue file, in order to use variables, etc.: <style lang="scss"> @import "../styles/settings.scss"; .someclass { color: $some-variable; } </style> or if it's nested in a folder I have to remember to be careful with the path: <style lang="scss"> @import "../../styles/settings.scss"; </style> Is there a way to globally import that settings.scss file in every .vue file I create? I looked in the docs and didn't see it, but maybe I missed it, or

vue 框架安装系列问题

情到浓时终转凉″ 提交于 2019-11-27 12:20:18
npm install --global vue-cli 错误提示:vue-cli-service' 不是内部或外部命令,也不是可运行的程序或批处理文件 解决: 如果是npm安装的 执行 npm -g bin 把地址添加到环境变量中 如果是yarn 安装的 执行 yarn global bin 把地址添加到环境变量中 运行:yarn run serve 下面为错误提示:(解决方法 :npm rebuild node-sass) yarn run v1.13.0 $ vue-cli-service serve INFO Starting development server... 64% building 543/596 modules 53 active ...les\core-js\library\modules\_defined.jsBrowserslist: caniuse-lite is outdated. Please run next command `yarn upgrade caniuse-lite browserslist` 98% after emitting CopyPlugin ERROR Failed to compile with 17 errors 10:21:18 AM error in ./src/components/error-page/403