- Vue.js 2 Design Patterns and Best Practices
- Paul Halliday
- 138字
- 2021-06-24 18:33:05
Vue-loader
Inside of our ./webpack-config.js within the standard webpack-simple template, we have a module object that allows us to set up our loader; this tells Webpack that we'd like it to use .vue files inside of our project:
module: {
rules: [{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {}
// other vue-loader options go here
}
}]
For this to work, Webpack runs a regular expression for anything that matches .vue and then passes this to our vue-loader to be transformed into a plain JavaScript module. In this simple example, we're loading files with a .vue extension, but vue-loader can be further customized and you may want to look into this further (https://goo.gl/4snNfD). We could certainly do this configuration ourselves, but hopefully, you can see the benefits of using the Vue CLI to generate our Webpack projects.
推薦閱讀
- 物聯(lián)網(wǎng)安全:理論、實踐與創(chuàng)新
- 電子政務(wù)效益的經(jīng)濟分析與評價
- Django 2 by Example
- 重新定義Spring Cloud實戰(zhàn)
- HCNA網(wǎng)絡(luò)技術(shù)
- Building RESTful Web services with Go
- Mastering Dart
- Android UI Design
- Microsoft Power Platform Enterprise Architecture
- 區(qū)塊鏈社區(qū)運營手冊
- Migrating to Drupal7
- XSS跨站腳本攻擊剖析與防御
- Twilio Cookbook(Second Edition)
- 深入淺出計算機網(wǎng)絡(luò)
- CiviCRM Cookbook