How do i add Hash to images and other assets in ionic












1














I am trying to fingerprint assets for cache busting in ionic so far I am able to fingerprint generated.js artifacts but unable to fingerPrint images and json files under assets.
I took Help from Bundled files and cache busting,.



This is my webpack config.js



    /*
* The webpack config exports an object that has a valid webpack configuration
* For each environment name. By default, there are two Ionic environments:
* "dev" and "prod". As such, the webpack.config.js exports a dictionary object
* with "keys" for "dev" and "prod", where the value is a valid webpack configuration
* For details on configuring webpack, see their documentation here
* https://webpack.js.org/configuration/
*/

var path = require('path');
var webpack = require('webpack');
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);

var ModuleConcatPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin');
var PurifyPlugin = require('@angular-devkit/build-optimizer').PurifyPlugin;

var optimizedProdLoaders = [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.js$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},
]
},
{
test: /.ts$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},

{
loader: process.env.IONIC_WEBPACK_LOADER
}
]
}
];

function getProdLoaders() {
if (process.env.IONIC_OPTIMIZE_JS === 'true') {
return optimizedProdLoaders;
}
return devConfig.module.loaders;
}

var devConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].[chunkhash:4].js',
devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},

devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.ts$/,
loader: process.env.IONIC_WEBPACK_LOADER
},
{
test: /.(jpg|jpeg|gif|png)$/,
exclude: /node_modules/,
loader:'url-loader?limit=1024&name=images/[name].[ext]'
},
{
test: /.(woff|woff2|eot|ttf|svg)$/,
exclude: /node_modules/,
loader: 'url-loader?limit=1024&name=fonts/[name].[ext]'
}
]
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};

var prodConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].js',

devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},
devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: getProdLoaders()
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin(),
new ModuleConcatPlugin(),
new PurifyPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};


module.exports = {
dev: devConfig,
prod: prodConfig
}


Expected o/p: images with hash for cache busting.










share|improve this question
























  • Did you run the build in prod mode?
    – emix
    16 hours ago










  • @emix yes I did AFAIK Angular provides us with output-hashing but ionic does not that's why I have moved to webpack config for hashing
    – Vikas
    16 hours ago
















1














I am trying to fingerprint assets for cache busting in ionic so far I am able to fingerprint generated.js artifacts but unable to fingerPrint images and json files under assets.
I took Help from Bundled files and cache busting,.



This is my webpack config.js



    /*
* The webpack config exports an object that has a valid webpack configuration
* For each environment name. By default, there are two Ionic environments:
* "dev" and "prod". As such, the webpack.config.js exports a dictionary object
* with "keys" for "dev" and "prod", where the value is a valid webpack configuration
* For details on configuring webpack, see their documentation here
* https://webpack.js.org/configuration/
*/

var path = require('path');
var webpack = require('webpack');
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);

var ModuleConcatPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin');
var PurifyPlugin = require('@angular-devkit/build-optimizer').PurifyPlugin;

var optimizedProdLoaders = [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.js$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},
]
},
{
test: /.ts$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},

{
loader: process.env.IONIC_WEBPACK_LOADER
}
]
}
];

function getProdLoaders() {
if (process.env.IONIC_OPTIMIZE_JS === 'true') {
return optimizedProdLoaders;
}
return devConfig.module.loaders;
}

var devConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].[chunkhash:4].js',
devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},

devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.ts$/,
loader: process.env.IONIC_WEBPACK_LOADER
},
{
test: /.(jpg|jpeg|gif|png)$/,
exclude: /node_modules/,
loader:'url-loader?limit=1024&name=images/[name].[ext]'
},
{
test: /.(woff|woff2|eot|ttf|svg)$/,
exclude: /node_modules/,
loader: 'url-loader?limit=1024&name=fonts/[name].[ext]'
}
]
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};

var prodConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].js',

devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},
devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: getProdLoaders()
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin(),
new ModuleConcatPlugin(),
new PurifyPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};


module.exports = {
dev: devConfig,
prod: prodConfig
}


Expected o/p: images with hash for cache busting.










share|improve this question
























  • Did you run the build in prod mode?
    – emix
    16 hours ago










  • @emix yes I did AFAIK Angular provides us with output-hashing but ionic does not that's why I have moved to webpack config for hashing
    – Vikas
    16 hours ago














1












1








1


1





I am trying to fingerprint assets for cache busting in ionic so far I am able to fingerprint generated.js artifacts but unable to fingerPrint images and json files under assets.
I took Help from Bundled files and cache busting,.



This is my webpack config.js



    /*
* The webpack config exports an object that has a valid webpack configuration
* For each environment name. By default, there are two Ionic environments:
* "dev" and "prod". As such, the webpack.config.js exports a dictionary object
* with "keys" for "dev" and "prod", where the value is a valid webpack configuration
* For details on configuring webpack, see their documentation here
* https://webpack.js.org/configuration/
*/

var path = require('path');
var webpack = require('webpack');
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);

var ModuleConcatPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin');
var PurifyPlugin = require('@angular-devkit/build-optimizer').PurifyPlugin;

var optimizedProdLoaders = [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.js$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},
]
},
{
test: /.ts$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},

{
loader: process.env.IONIC_WEBPACK_LOADER
}
]
}
];

function getProdLoaders() {
if (process.env.IONIC_OPTIMIZE_JS === 'true') {
return optimizedProdLoaders;
}
return devConfig.module.loaders;
}

var devConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].[chunkhash:4].js',
devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},

devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.ts$/,
loader: process.env.IONIC_WEBPACK_LOADER
},
{
test: /.(jpg|jpeg|gif|png)$/,
exclude: /node_modules/,
loader:'url-loader?limit=1024&name=images/[name].[ext]'
},
{
test: /.(woff|woff2|eot|ttf|svg)$/,
exclude: /node_modules/,
loader: 'url-loader?limit=1024&name=fonts/[name].[ext]'
}
]
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};

var prodConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].js',

devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},
devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: getProdLoaders()
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin(),
new ModuleConcatPlugin(),
new PurifyPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};


module.exports = {
dev: devConfig,
prod: prodConfig
}


Expected o/p: images with hash for cache busting.










share|improve this question















I am trying to fingerprint assets for cache busting in ionic so far I am able to fingerprint generated.js artifacts but unable to fingerPrint images and json files under assets.
I took Help from Bundled files and cache busting,.



This is my webpack config.js



    /*
* The webpack config exports an object that has a valid webpack configuration
* For each environment name. By default, there are two Ionic environments:
* "dev" and "prod". As such, the webpack.config.js exports a dictionary object
* with "keys" for "dev" and "prod", where the value is a valid webpack configuration
* For details on configuring webpack, see their documentation here
* https://webpack.js.org/configuration/
*/

var path = require('path');
var webpack = require('webpack');
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);

var ModuleConcatPlugin = require('webpack/lib/optimize/ModuleConcatenationPlugin');
var PurifyPlugin = require('@angular-devkit/build-optimizer').PurifyPlugin;

var optimizedProdLoaders = [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.js$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},
]
},
{
test: /.ts$/,
loader: [
{
loader: process.env.IONIC_CACHE_LOADER
},

{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: false
}
},

{
loader: process.env.IONIC_WEBPACK_LOADER
}
]
}
];

function getProdLoaders() {
if (process.env.IONIC_OPTIMIZE_JS === 'true') {
return optimizedProdLoaders;
}
return devConfig.module.loaders;
}

var devConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].[chunkhash:4].js',
devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},

devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: [
{
test: /.json$/,
loader: 'json-loader'
},
{
test: /.ts$/,
loader: process.env.IONIC_WEBPACK_LOADER
},
{
test: /.(jpg|jpeg|gif|png)$/,
exclude: /node_modules/,
loader:'url-loader?limit=1024&name=images/[name].[ext]'
},
{
test: /.(woff|woff2|eot|ttf|svg)$/,
exclude: /node_modules/,
loader: 'url-loader?limit=1024&name=fonts/[name].[ext]'
}
]
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};

var prodConfig = {
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
publicPath: 'build/',
filename: '[name].js',

devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},
devtool: process.env.IONIC_SOURCE_MAP_TYPE,

resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

module: {
loaders: getProdLoaders()
},

plugins: [
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin(),
new ModuleConcatPlugin(),
new PurifyPlugin()
],

// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};


module.exports = {
dev: devConfig,
prod: prodConfig
}


Expected o/p: images with hash for cache busting.







javascript angular webpack ionic3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 15 hours ago

























asked 16 hours ago









Vikas

5,67821231




5,67821231












  • Did you run the build in prod mode?
    – emix
    16 hours ago










  • @emix yes I did AFAIK Angular provides us with output-hashing but ionic does not that's why I have moved to webpack config for hashing
    – Vikas
    16 hours ago


















  • Did you run the build in prod mode?
    – emix
    16 hours ago










  • @emix yes I did AFAIK Angular provides us with output-hashing but ionic does not that's why I have moved to webpack config for hashing
    – Vikas
    16 hours ago
















Did you run the build in prod mode?
– emix
16 hours ago




Did you run the build in prod mode?
– emix
16 hours ago












@emix yes I did AFAIK Angular provides us with output-hashing but ionic does not that's why I have moved to webpack config for hashing
– Vikas
16 hours ago




@emix yes I did AFAIK Angular provides us with output-hashing but ionic does not that's why I have moved to webpack config for hashing
– Vikas
16 hours ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942876%2fhow-do-i-add-hash-to-images-and-other-assets-in-ionic%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942876%2fhow-do-i-add-hash-to-images-and-other-assets-in-ionic%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Error while reading .h5 file using the rhdf5 package in R

Pushsharp Apns notification error: 'InvalidToken'