我剛剛開始了一個webpack的反應項目,我試圖編譯我的sass文件並使用webpack導出到css,但似乎沒有發生任何事情。我沒有收到任何錯誤,但我沒有看到任何.css文件的項目。任何建議都會很棒。使用webpack編譯sass並導出到css 2
我的WebPack配置如下:
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './src/app.js',
output: { path: __dirname, filename:'./dist/bundle.js' },
module: {
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: { presets: ['es2015', 'react'] }
},{
rules: [{
test: /\.scss$/,
use: [
{loader: "style-loader"},
{loader: "css-loader"},
{loader: "sass-loader"}
]
}]
}]
},
plugins: [new ExtractTextPlugin('../src/css/main.css')]
};
這裏是版本的/ dev依賴我使用:
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^6.3.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^2.0.0-rc.3",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"rimraf": "^2.6.0",
"sass-loader": "^6.0.1",
"style-loader": "^0.13.1",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
}
提前感謝! :)
我看到你正在使用CSS的ExtractTextPlugin,但不是scss。您是否還將scss文件導入到.js文件中? –
您是否已將任何'.scss'文件導入您的條目文件或其任何導入的文件? –
謝謝你們,我沒有輸入文件。當我作爲SCSS導入並且cix爲SCSS提取時它可以工作 - 這是個好消息,但現在我的問題是我想編寫SASS,當我將ExtractText更改爲sass並導入時出現錯誤「您可能需要適當的加載器來處理這種文件類型。「 – ironmike