Webpack - сжатие файлов json
Привет всем!
Не могу настроить webpack. Он почему то не сжимает файлы json, хотя css и js создает без проблем. Вот мой webpack.config.json: const path = require('path'); const webpack = require('webpack'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const CompressionPlugin = require("compression-webpack-plugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const PostCSSAssetsPlugin = require('postcss-assets-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = function (env) { const outputPath = path.join(__dirname, '../back-end/data'); const exports = { cache: true, entry: {main: './src/index'}, output: { path: outputPath, filename: '[name].js', publicPath: '/' }, plugins: [ new CleanWebpackPlugin(path.join(outputPath, '*'), {root: path.join(__dirname, '..'), verbose: false}), new webpack.NoEmitOnErrorsPlugin(), new ExtractTextPlugin('style.css'), new PostCSSAssetsPlugin({ test: /\.css$/, log: false, plugins: [ require('precss'), require('autoprefixer') ], }) ], module: { rules: [ { test: /\.js$/, loader: 'babel-loader', include: [path.resolve(__dirname, "src")], exclude: /(node_modules|bower_components)/, options: {cacheDirectory: path.resolve(__dirname, 'babel_cache/')} }, { test: /\.s?css$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: ['css-loader', 'sass-loader'] }) }, { test: /\.json$/, loader: 'json-loader' } ] } }; const copyTargets = [ {from: 'src/static/', to: './'} ]; exports.plugins.push(new CopyWebpackPlugin(copyTargets)); if (env && env.compress) { exports.plugins.push(new CompressionPlugin({ asset: "[path].gz[query]", algorithm: "gzip", test: /\.(js|css|json)$/, threshold: 8192, minRatio: 0.8, deleteOriginalAssets: true })); } return exports; }; Я в конце копирую из папки src/static/ в выходную папку ../back-end/data. И в выходной папке ../back-end/data/dl/ хочу сжать все файлы json (там только json) Помогите разобраться, что не так. |
Часовой пояс GMT +3, время: 11:48. |