0
我無法使用webpack加載我的樣式 - 我有幾個.scss
文件,webpack應該將它們編譯爲.css
文件並生成JS輸出文件。該文件生成正確,但.css
文件只是不存在。有什麼可以不對我的配置?:Css未裝入webpack
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')
const DIST_DIR = path.resolve(__dirname, 'dist');
const APP_DIR = path.resolve(__dirname, 'src');
const sassLoaders = [
'css-loader',
'sass-loader?indentedSyntax=sass&includePaths[]=' + DIST_DIR
]
const config = {
entry: {
app: [APP_DIR + '/index.js']
},
module: {
loaders: [
{
test: /\.jsx$/,
include: APP_DIR,
loaders: ['babel']
},
{
test: /\.scss$/,
include: DIST_DIR,
loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!'))
}
]
},
output: {
filename: 'js/bundle.js',
path: DIST_DIR
},
plugins: [
new ExtractTextPlugin('[name].css')
],
resolve: {
extensions: ['', '.js', '.scss'],
root: [APP_DIR]
}
}
module.exports = config
文件結構:
dist
- css
- style.scss
- js
src
- index.js
你應該匹配針對' .scss'擴展名不是'.sass'。嘗試將'test'鍵更改爲'/ \。scss $ /' –
當然,只是一個錯字,它不會改變我的情況。 – user99999