Webpack文件加载器无法在dist中创建或复制文件

时间:2016-10-27 21:12:43

标签: node.js webpack webpack-2 webpack-file-loader

嘿伙计们(使用webpack 2.1.0-beta.22)所以我在webpack.base.js中有以下配置:

entry: {
    client: "./client/index.js"
},
output: {
    path: _.outputPath,
    filename: '[name].js',
    publicPath: '/themes/default/dist/'
},
module: {
    loaders: [
        {
            test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
            loader: 'file',
            query: {
                name: 'media/[name].[hash:8].[ext]'
            }
        }
    ]
}

这是我的webpack.dev.js

const cssImagePath = path.resolve('../..');`

base.module.loaders.push(
    {
        test: /\.(s?)css$/,
        loaders: [
            'style-loader',
            `css-loader?sourceMap&root=${cssImagePath}`,
            'sass-loader?outputStyle=expanded&sourceMap&sourceMapContents'
        ]
    }
)

现在我在scss文件中添加了这一行:background-image: url('/themes/default/client/images/snow-flake.png');

如果我运行webpack并使用检查器,则路径将被替换为:url(/themes/default/dist/media/snow-flake.0af467e3.png)

哪个看起来很完美的问题是file-loader没有创建/复制到该目录,因此themes/default/dist/media不存在?

有人遇到过这个吗?

0 个答案:

没有答案