在webpack.config.js中添加include时,css-loader失败

时间:2016-09-19 01:58:53

标签: webpack webpack-style-loader css-loader

我有一个webpack.config.js文件:

let webpack = require('webpack');

module.exports = {
    entry: './src/test.css',
    output: {
        path: "dist",
        filename: "app.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, include: ["E:\demo\src"], loaders: ["style", "css"] }
        ]
    }
}

但是,它失败了。错误消息是:

ERROR in ./src/test.css
Module parse failed: e:\demo\webpack-demo\src\test.css Unexpected token (1:4)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:4)
    at Parser.pp$4.raise (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp.unexpected (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:603:10)
    at Parser.pp.semicolon (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:966:10)
    at Parser.pp$1.parseStatement (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:730:24)
    at Parser.pp$1.parseTopLevel (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:638:25)
    at Parser.parse (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:516:17)
    at Object.parse (E:\demo\webpack-demo\node_modules\acorn\dist\acorn.js:3098:39)
    at Parser.parse (E:\demo\webpack-demo\node_modules\webpack\lib\Parser.js:902:15)
    at DependenciesBlock.<anonymous> (E:\demo\webpack-demo\node_modules\webpack\lib\NormalModule.js:104:16)
    at DependenciesBlock.onModuleBuild (E:\demo\webpack-demo\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
    at nextLoader (E:\demo\webpack-demo\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
    at E:\demo\webpack-demo\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
    at Storage.finished (E:\demo\webpack-demo\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
    at E:\demo\webpack-demo\node_modules\graceful-fs\graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)

但删除 include 时成功。我的文件目录是:

enter image description here

0 个答案:

没有答案