0

我的 webpack 配置有问题。它运行没有错误,但不输出除 app.js 和 index.html 之外的任何文件。应用遗传样式。唯一不起作用的是字体

webpack 版本 ^3.5.6 extractTest 版本 ^3.0.0

const path = require('path');
const extractText = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');

const isProd = process.env.NODE_ENV === 'prod';
const cssDev = ['style-loader', 'css-loader', 'sass-loader'];
const cssProd = extractText.extract({
    filename: 'styles.css',
    fallback: 'style-loader',
    use: 'css-loader!sass-loader',
    publicPath: '/dist',

})

const cssConfig = isProd ? cssProd : cssDev;

module.exports = {
    entry: './src/index.js',
    output: {
        path: path.resolve(__dirname, 'dev'),
        filename: 'app.bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: [/node_modules/, /__tests__/],
                use: 'babel-loader'
            },
            {
                test: /\.sass$/,
                use: cssConfig
            },
            {
                test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
                loader: 'file-loader'
            }
        ]
    },
    devServer: {
        historyApiFallback: true,
        contentBase: path.join(__dirname, 'dist'),
        compress: true,
        port: 3000,
        stats: 'errors-only'
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'Recipes',
            hash: true,
            template: './src/index.ejs'
        }),
        new extractText('style.css'),
        new webpack.HotModuleReplacementPlugin()

    ]
}
4

0 回答 0