Comments (10)
I am also interested in a solution to this problem, not certain where the issue stems from...
from compression-webpack-plugin.
I can confirm that this PR fixed by issues with the following config:
plugins: [
new CopyWebpackPlugin([{
from: path.resolve(__dirname, '../my-other-project/dist'),
to: 'static'
}]),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.(js|html|css)$/
})
]
from compression-webpack-plugin.
@nmcclay why don't use https://github.com/perchlayer/po-loader or https://github.com/queicherius/i18next-po-loader for this purpose?
from compression-webpack-plugin.
The problem was the order of execution for generating gzip compression after copying an external SPA app directory in my case, not moving .po files. The issue just manifests as the same issue, that the CompressorPlugin wasn't running AFTER the copy plugin. Using this fork effectively fixed that load issue in my case.
from compression-webpack-plugin.
@nmcclay Can you say what actually solved you problem?
My config:
new CopyWebpackPlugin([
{
from: path.join(__dirname, 'dev/json/info.json'),
to: 'json/info.json'
}
]),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.json$|\.css$|\.html$/,
deleteOriginalAssets: true
})
info.json is not gzipped in this case
from compression-webpack-plugin.
Its either that your path configuration is too rigid for CopyWebpackPlugin, or your CompressionPlugin test is incorrect, not sure which. This configuration works with .json files for me:
plugins: [
new CopyWebpackPlugin([{
from: path.resolve(__dirname, '../my-other-project/dist'),
to: 'static'
}]),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.(js|css|json)$/
})
]
from compression-webpack-plugin.
dependencies, note that I'm using aforementioned forked version of compression-webpack-plugin:
"webpack": "^3.4.1",
"compression-webpack-plugin": "github:ijpiantanida/compression-webpack-plugin#emit-event",
"copy-webpack-plugin": "^4.0.1",
from compression-webpack-plugin.
This helped and json is gzipped:
"compression-webpack-plugin": "github:ijpiantanida/compression-webpack-plugin#emit-event",
but now flag deleteOriginalAssets doesn't work.
Thanks for the tip
from compression-webpack-plugin.
I have also same problem angular4 component bundling not working in firefox fix is below
Chrome/63.0.3239.132 Safari/537.36
but not working with Firefox/57.0
app.get('*.js', function (req, res, next) { req.url = req.url + '.gz'; res.set('Content-Encoding', 'gzip'); res.set('Content-Type', 'text/javascript'); next(); });
from compression-webpack-plugin.
I'm still having this issue, i have tried downgrading using the forked repo and nothing has this been fixed yet?
Dependencies
"compression-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^6.0.3",
webpack.config.js
const HtmlWebPackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const MinifyPlugin = require('babel-minify-webpack-plugin');
module.exports = {
context: __dirname,
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js',
publicPath: '/',
},
devServer: {
historyApiFallback: true,
},
resolve: {
extensions: ['.js', '.jsx', '.less', '.css'],
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
plugins: [['import', { libraryName: 'antd', style: true }]],
},
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
],
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[name]__[local]___[hash:base64:5]',
},
sourceMap: true,
},
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [autoprefixer({})],
},
},
],
},
{
test: /\.(png|jpe?g|gif)$/,
loader: 'url-loader?limit=10000&name=img/[name].[ext]',
},
],
},
plugins: [
new MinifyPlugin(),
new ManifestPlugin({ fileName: 'file-manifest.json' }),
new CopyPlugin([
{
from: 'public',
to: 'dist',
globOptions: {
ignore: ['**/index.html'],
},
},
]),
new CompressionPlugin({
algorithm: 'gzip',
cache: false,
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false,
}),
new CompressionPlugin({
filename: '[path].br[query]',
algorithm: 'brotliCompress',
test: /\.(js|css|html|svg)$/,
compressionOptions: {
level: 11,
},
cache: false,
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false,
}),
new HtmlWebPackPlugin({
template: path.resolve(__dirname, 'public/index.html'),
filename: 'index.html',
}),
],
};
from compression-webpack-plugin.
Related Issues (20)
- [types] Failed to import new types HOT 3
- [types] `@gfx/zopfli` can't be used with new types HOT 3
- Getting error TS1005: '?' expected HOT 2
- Always 404, I don't know why, HOT 2
- gzipped css not updated in html file HOT 19
- compress images not work HOT 2
- TypeError: Cannot read properties of undefined (reading 'tapPromise') HOT 1
- Allow usage of 6.x version without md4 HOT 4
- ERROR in Conflict: Multiple assets emit different content to the same filename css/.gz HOT 1
- Restoring failed for CompressionWebpackPlugin; HookWebpackError: this._obj.updateHash is not a function HOT 5
- Some of the files ignored during build compression HOT 10
- How to do this compression from express? HOT 1
- How to use deleteOriginalAssets is true ? HOT 2
- Compressed build now working on browser HOT 6
- Version 6 (for Webpack 4) does not work on Node 18+ HOT 10
- Let users exclude files or folder from deleting original assets. HOT 1
- Compression-webpack-plugin running before HtmlCriticalWebpackPlugin completes. HOT 2
- Ability to exclude files from deletion after zipping. HOT 1
- Type definition `BasePluginOptions` property `test` should use `Rules`, not `Rule`
- compression-webpack-plugin .woff compression is not supported HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compression-webpack-plugin.