npm install node-sass --save-dev
npm install sass-loader --save-dev
2、sass全局引用
npm install --save-dev sass-resources-loader
配置build/utils.js
function resolveResource(name) {
return path.resolve(__dirname, '../static/style/' + name)
}
function generateSassResourceLoader() {
var loaders = [
cssLoader,
'sass-loader',
{
loader:'sass-resources-loader',
options: {
// 多个文件时用数组的形式传入,单个文件时可以直接使用path.resolve(__dirname, '../static/style/blog.scss'
resources: [resolveResource('blog.scss')]
}
}
]
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback:'vue-style-loader'
})
}else {
return ['vue-style-loader'].concat(loaders)
}
}
return {
css:generateLoaders(),
postcss:generateLoaders(),
less:generateLoaders('less'),
// sass: generateLoaders('sass', { indentedSyntax: true }),
// scss: generateLoaders('sass'),
//配置sass-resources-loader
sass:generateSassResourceLoader(),
scss:generateSassResourceLoader(),
stylus:generateLoaders('stylus'),
styl:generateLoaders('stylus')
}
报错内容
Module build failed: Error: Missing binding /Users/jac/Downloads/country/node_modules/node-sass/vendor/darwin-x64-
59/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 9.x
Found bindings for the following environments:
- OS X 64-bit with Node.js 6.x
因为sass对node 8x+版本不兼容
解决方法
npm i node-sass -D
亲测有效
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)