如何让 webpack、sass 和 source maps 在多页面应用程序中运行?
How to make webpack, sass and source maps go along in a multi page app?
这是我现在所在的位置:
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
:
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
:
require('./1.sass');
1.sass
:
body
background: #ddd
然后
$ rm -f dist/* && ./node_modules/.bin/webpack
并在 Chrome 中打开 http://example.com/dist
。然后打开Developer Tools
> Sources
> top
> webpack://
> .
> 1.sass
。在那里您会看到 css 代码,而不是 sass 代码。 devtool
用于 js/coffeescript/whatever,如果有的话。我做错了什么?
UPD
据我所知,sass-loader
出于某种原因传递了文件 as a string. And in that case node-sass
(libsass
) doesn't return source map. But even if given file, the latter returns source map with generated css code,而不是 sass 代码。欢迎任何解决方法,即使丑陋。
嗯,libsass
没有为内联内容生成源映射的问题似乎是 taken care of. It's just that libsass
returns source maps with scss code,即使给定 sass 代码也是如此。所以我误认为是 css.
这是我现在所在的位置:
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
:
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
:
require('./1.sass');
1.sass
:
body
background: #ddd
然后
$ rm -f dist/* && ./node_modules/.bin/webpack
并在 Chrome 中打开 http://example.com/dist
。然后打开Developer Tools
> Sources
> top
> webpack://
> .
> 1.sass
。在那里您会看到 css 代码,而不是 sass 代码。 devtool
用于 js/coffeescript/whatever,如果有的话。我做错了什么?
UPD
据我所知,sass-loader
出于某种原因传递了文件 as a string. And in that case node-sass
(libsass
) doesn't return source map. But even if given file, the latter returns source map with generated css code,而不是 sass 代码。欢迎任何解决方法,即使丑陋。
嗯,libsass
没有为内联内容生成源映射的问题似乎是 taken care of. It's just that libsass
returns source maps with scss code,即使给定 sass 代码也是如此。所以我误认为是 css.