Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why resolve with file-loader not work ? #235

Open
pejman-hkh opened this issue Sep 30, 2023 · 0 comments
Open

Why resolve with file-loader not work ? #235

pejman-hkh opened this issue Sep 30, 2023 · 0 comments

Comments

@pejman-hkh
Copy link

My config file :

const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const devMode = process.env.NODE_ENV !== "production";

const path = require('path');

module.exports = {
    mode : 'development',
    entry: [
        __dirname + '/src/app.js',
        __dirname + '/src/app.scss'
    ],
    output: {
        path: path.resolve(__dirname, 'dist'), 
        filename: 'app.min.js',
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: [],
            }, {
                test: /\.min\.js$/,
                use: [ 'script-loader' ]            
            },
            {
                test: /\.scss$/,
                exclude: /node_modules/,
                use: [

                    devMode ? "style-loader" : MiniCssExtractPlugin.loader,
                         
                    {
                        loader: 'file-loader',
                        options: { outputPath: './', name: '[name].min.css'}
                    },
                    {
                        loader: 'resolve-url-loader',
                        options: {
                                             
                        }
                    },                                      
                    {
                        loader: 'sass-loader',
                        options: {
                            sourceMap: true,
                        }
                    },
                ]
            },
            {
                test: /\.(woff(2)?|ttf|eot|svg|otf|jpeg|jpg|png)$/,
                loader: 'file-loader',
                exclude: /node_modules/,
                options: {
                    name: '[path][name].[ext]?[hash]',
                    outputPath: './'
                }
            },                       
        ]
    },
    plugins: [].concat(devMode ? [] : [new MiniCssExtractPlugin()]),
    devServer: {
    static: {
        directory: path.join(__dirname, 'dist'),
    },
    compress: true,
    port: 9000,
    },

};

When I add css-loader to this file-loader not work.
Is there any option for save file with same name and directory ? Or just change urls and create files with file-loader and use it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant