[英]How to make webpack, sass and source maps go along in a multi page app?
Here's where I'm now: 这是我现在的位置:
package.json
: package.json
:
{
"dependencies": {
"css-loader": "^0.26.0",
"html-webpack-plugin": "^2.24.1",
"node-sass": "^3.13.0",
"sass-loader": "^4.0.2",
"style-loader": "^0.13.1",
"webpack": "^1.13.3"
}
}
webpack.config.js
: webpack.config.js
:
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './1.js',
output: {
path: 'dist',
filename: 'bundle.js',
},
module: {
loaders: [
{test: /\.sass$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']},
]
},
plugins: [
new HtmlWebpackPlugin,
],
};
1.js
: 1.js
:
require('./1.sass');
1.sass
: 1.sass
:
body
background: #ddd
Then 然后
$ rm -f dist/* && ./node_modules/.bin/webpack
And open http://example.com/dist
in Chrome. 然后在Chrome中打开http://example.com/dist
。 Then open Developer Tools
> Sources
> top
> webpack://
> .
然后打开Developer Tools
> Sources
> top
> webpack://
> .
> 1.sass
. > 1. 1.sass
。 And there you'll see css code, not sass code. 在这里,您会看到CSS代码,而不是SASS代码。 devtool
is for js/coffeescript/whatever, if anything. devtool
适用于js / coffeescript /(无论如何)。 What am I doing wrong? 我究竟做错了什么?
UPD UPD
From what I can see, sass-loader
passes file as a string . 从我可以看到, sass-loader
将文件作为字符串传递。 And in that case node-sass
( libsass
) doesn't return source map. 在这种情况下, node-sass
( libsass
)不返回源映射。 But even if given file, the latter returns source map with generated css code , not sass code for some reason. 但是即使给定文件,由于某种原因,后者也会返回带有生成的css代码而不是sass代码的源映射。 Any workarounds are welcome, even if ugly. 任何变通方法都可以接受,即使很难看。
Well, the issue with libsass
not generating source maps for inline content seems to be taken care of . 好了,这个问题libsass
不产生源地图内嵌的内容似乎是照顾 。 It's just that libsass
returns source maps with scss code , even if given sass code. 只是libsass
返回带有scss代码的源映射,即使给出了sass代码也是如此。 So I mistook it for css. 所以我误认为它的CSS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.