Search code examples
javascriptimagejquery-uiwebpackwebpack-file-loader

Load assets from jQuery UI in webpack using file loader


I want to have jQuery ui assets in folder /dist/ and they should be loaded from an app. I have this in my webpack config:

module.exports = {
    context: path.resolve(__dirname, "app"),
    output: {
        path: __dirname + '/dist',
        filename: 'app.bundle.js' 
    },
    module: {
        loaders: [
            {
                test: /\.css$/,
                loaders: [
                    'style-loader',
                    'css-loader?importLoaders=1',
                    'postcss-loader'
                ]
            },
            {
                test: /\.(jpe?g|png|gif|svg)$/i,
                loaders: [
                    'file?hash=sha512&digest=hex&name=[hash].[ext]',
                    'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
                ]
            }
        ]
    }
};

and it try to load assets from root directory and not from /dist the image files are located in dist directory.

I've try to add dist to name:

'file?hash=sha512&digest=hex&name=dist/[hash].[ext]'

the images are loading but then I have directory dist/dist with image files. I've try to add ./ but images are not loaded. Also I've try to set outputPath=/dist/ but that didn't change anything.


Solution

  • this work:

    file?hash=sha512&digest=hex&name=[hash].[ext]&publicPath=dist/