webpack 2.7.0加载程序配置

时间:2017-07-20 10:01:29

标签: webpack loader

我疯狂地处理webpack。我似乎无法以正确的方式配置我的webpack.config.js。

这是我的网站:

const path = require('path');

module.exports = {
    entry: './src/app.js', //Entrypoint of the app, what code to read
    output: { //tells webpack where to output the bundled file
        path: path.resolve(__dirname, 'public'),
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude:/node_modules/,
                use: [
                    {
                        loader: 'babel-loader',
                        options: {
                                presets: ['react', 'es2015', 'stage-1'], //tells babel compiler to transform ES6/es2015 ES6/stage-1 JS version into a JS version comp with the browsers, react tells WP to compile jsx into javascript,
                        }
                    }
                ]
            },
            {
                test: /\.css$/,
                use: 'css-loader'
            },
            {
                test: /\.scss$/,
                use: [{
                    loader: "style-loader"
                }, {
                    loader: "css-loader", options: {
                        sourceMap: true
                    }
                }, {
                    loader: "sass-loader", options: {
                        sourceMap: true
                    }
                }]
            },
            {
                test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/font-woff"
            }, {
                test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/font-woff"
            }, {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/octet-stream"
            }, {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                loader: "file"
            }, {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=image/svg+xml"
            }

        ]
    },
    devtool: "#eval-source-map", //maps the bundle to readable code
    watch: true
}

这是错误:

ERROR in ./~/css-loader?{"sourceMap":true}!./~/sass-loader/lib/loader.js?{"sourceMap":true}!./public/css/demo.scss
Module build failed: 
        border: 1px solid $default-border-color;
                         ^
      Undefined variable: "$default-border-color".
      in /Users/Markus/WebstormProjects/intra/public/css/demo.scss (line 9, column 27)
 @ ./public/css/demo.scss 4:14-142
 @ ./src/app.js

有人可以给我一些可能不正确的指示吗?

0 个答案:

没有答案