Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack 创建一个基本的网页包设置以输出css_Webpack - Fatal编程技术网

Webpack 创建一个基本的网页包设置以输出css

Webpack 创建一个基本的网页包设置以输出css,webpack,Webpack,我正在尝试创建一个超级简单的网页包,用于从sass创建css 我有以下文件: index.html entry.js package.json webpack.config.js css -app.scss index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </h

我正在尝试创建一个超级简单的网页包,用于从sass创建css

我有以下文件:

index.html
entry.js
package.json
webpack.config.js
css
-app.scss

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>

<script type="text/javascript" src="bundle.js" charset="utf-8"></script>
</body>

</html>
package.json:

{
  "name": "ls",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack-dev-server"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer-loader": "^3.2.0",
    "css-loader": "^1.0.0",
    "node-sass": "^4.9.2",
    "postcss-loader": "^2.1.6",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.21.0",
    "svg-sprite-loader": "^3.8.0",
    "ts-loader": "^4.4.2",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.5"
  }
}
webpack.config.js:

module.exports = {
    entry: "./entry.js",
    output: {
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            {
                test: /\.scss$/,
                use: [ 'style-loader','css-loader','postcss-loader' ]
            }
        ]
    }
};
app.scss:

*{
  color: red;
}
如果我运行
npm start
我会得到错误
错误:找不到模块“webpack”

如何设置此选项以从app.scss文件输出css

更新

我安装了webpack,现在出现以下错误

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'loaders'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
   -> Options affecting the normal modules (`NormalModuleFactory`).

安装网页包:
npm安装--保存开发人员网页包
。你错过了。现在我得到了完全不同的东西——我更新了我的问题
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module has an unknown property 'loaders'. These properties are valid:
   object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, noParse?, rules?, defaultRules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictExportPresence?, strictThisContextOnImports? }
   -> Options affecting the normal modules (`NormalModuleFactory`).
module.exports = {
    entry: "./entry.js",
    output: {
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        rules: [
            {
                test: /\.scss$/,
                use: [ 'style-loader','css-loader','postcss-loader' ]
            }
        ]
    }
};