作者:倒退淂磁带_628 | 来源:互联网 | 2023-05-19 03:44
Iamtryingtoget*.scssfilestobesupportedinmywebpackconfigurationbutIkeepgettingthef
I am trying to get *.scss files to be supported in my webpack configuration but I keep getting the following error when I run the webpack build command:
我试图在我的webpack配置中获得* .scss文件,但是当我运行webpack build命令时,我一直收到以下错误:
ERROR in ./~/css-loader!./~/sass-loader!./app/styles.scss
Module build failed: TypeError: Cannot read property 'sections' of null
at new SourceMapConsumer (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/node_modules/postcss/node_modules/source-map/lib/source-map/source-map-consumer.js:23:21)
at PreviousMap.consumer (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/node_modules/postcss/lib/previous-map.js:37:34)
at new Input (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/node_modules/postcss/lib/input.js:42:28)
at parse (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/node_modules/postcss/lib/parse.js:17:17)
at new LazyResult (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/node_modules/postcss/lib/lazy-result.js:54:47)
at Processor.process (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/node_modules/postcss/lib/processor.js:30:16)
at processCss (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/lib/processCss.js:168:24)
at Object.module.exports (/Users/sean/Development/playground/webpack.sass.test/node_modules/css-loader/lib/loader.js:21:15)
@ ./app/styles.scss 4:14-117
I can't for the life of me figure out why. It's a very basic setup.
我不能为我的生活找出原因。这是一个非常基本的设置。
I have created a dropbox share with the bare minimum illustrating this: https://www.dropbox.com/s/quobq29ngr38mhx/webpack.sass.test.zip?dl=0
我创建了一个Dropbox共享,最低限度说明了这一点:https://www.dropbox.com/s/quobq29ngr38mhx/webpack.sass.test.zip?dl = 0
Unzip this then run:
解压缩然后运行:
npm install
webpack
Here is my webpack.config.js file:
这是我的webpack.config.js文件:
var path = require('path')
var webpack = require('webpack')
module.exports = {
devtool: 'eval',
entry: [
'./app'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js',
publicPath: '/dist/'
},
plugins: [
new webpack.NoErrorsPlugin()
],
resolve: {
extensions: ['', '.js']
},
module: {
loaders: [{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
}]
}
}
And the index.js entry file:
和index.js条目文件:
require('./styles.scss');
alert('foo bar baz');
And the styles.scss file:
和styles.scss文件:
body {
background-color: #000;
}
It appears to follow the recommendations of the sass-loader documentation site, but I can't get it to run.
它似乎遵循sass-loader文档站点的建议,但我无法运行它。
:(
:(
Information about my environment:
有关我的环境的信息:
node - 0.12.4
npm - 2.10.1
os - OS X Yosemite
3 个解决方案