VUE2.0使用 SCSS
阿新 • • 發佈:2018-12-16
第一步
npm install node-sass --save-dev
npm install sass-loader --save-dev
如果出現下載意外,使用淘寶映象
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install node-sass --save
第二步
開啟webpack.base.config.js在loaders裡面加上 module – rules配置 我這是全部的module-rules配置
module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', options: vueLoaderConfig }, { test: /\.js$/, loader: 'babel-loader', include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, { test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('media/[name].[hash:7].[ext]') } }, { test: /\.scss$/, loaders: ["style", "css", "sass"] }, { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } } ] }
然後使用吧(記住包裹)
<style lang="scss" scoped> </style>