一,使用save會在package.json中自動添加。css
能夠經過淘寶的npm鏡像安裝node-sassvue
$ npm install -g cnpm --registry=https://registry.npm.taobao.org (安裝淘寶鏡像)node
$ cnpm install node-sass --save (使用淘寶鏡像安裝node-sass)webpack
注:安裝淘寶鏡像後,仍沒法安裝node-sass的狀況,執行下列命令web
1npm 2json 3sass 4babel 5svg 6 7 8 9 |
$ npm install --save node-sass --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist --sass-binary-site=http://npm.taobao.org/mirrors/node-sass 說明: --registry=https://registry.npm.taobao.org 淘寶npm包鏡像 --disturl=https://npm.taobao.org/dist 淘寶node源碼鏡像,一些二進制包編譯時用 --sass-binary-site=http://npm.taobao.org/mirrors/node-sass 這個纔是node-sass鏡像 |
2.打開webpack.base.config.js在loaders裏面加上 module -- rules (vue2.0)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
rules: [ { test: /\.vue$/, loader: 'vue-loader', options: vueLoaderConfig }, { test: /\.js$/, loader: 'babel-loader', include: [resolve('src'), resolve('test')] }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url-loader', query: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, { test: /\.scss$/, loaders: ["style", "css", "sass"] }, { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, loader: 'url-loader', query: { limit: 10000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } } ] } |
3.若是須要在vue文件style標籤使用scss的話,須要聲明一下:
vue2.0
1 |
< style lang="scss" scoped="" type="text/css"></ style > |