mirror of
https://github.com/ansible/awx.git
synced 2026-02-03 10:38:15 -03:30
Make asset hashes unique per file instead of per build
This commit is contained in:
@@ -27,7 +27,7 @@ const VENDOR_ENTRY = path.join(SOURCE_PATH, 'vendor.js');
|
|||||||
const INDEX_ENTRY = path.join(CLIENT_PATH, 'index.template.ejs');
|
const INDEX_ENTRY = path.join(CLIENT_PATH, 'index.template.ejs');
|
||||||
const INDEX_OUTPUT = path.join(UI_PATH, 'templates/ui/index.html');
|
const INDEX_OUTPUT = path.join(UI_PATH, 'templates/ui/index.html');
|
||||||
const THEME_ENTRY = path.join(LIB_PATH, 'theme', 'index.less');
|
const THEME_ENTRY = path.join(LIB_PATH, 'theme', 'index.less');
|
||||||
const OUTPUT = 'js/[name].[hash].js';
|
const OUTPUT = 'js/[name].[chunkhash].js';
|
||||||
const CHUNKS = ['vendor', 'app'];
|
const CHUNKS = ['vendor', 'app'];
|
||||||
|
|
||||||
const VENDOR = VENDOR_ENTRY;
|
const VENDOR = VENDOR_ENTRY;
|
||||||
@@ -108,7 +108,7 @@ const base = {
|
|||||||
CodeMirror: 'codemirror',
|
CodeMirror: 'codemirror',
|
||||||
jsonlint: 'codemirror.jsonlint'
|
jsonlint: 'codemirror.jsonlint'
|
||||||
}),
|
}),
|
||||||
new ExtractTextPlugin('css/[name].[hash].css'),
|
new ExtractTextPlugin('css/[name].[chunkhash].css'),
|
||||||
new CleanWebpackPlugin([STATIC_PATH, COVERAGE_PATH, LANGUAGES_PATH], {
|
new CleanWebpackPlugin([STATIC_PATH, COVERAGE_PATH, LANGUAGES_PATH], {
|
||||||
root: UI_PATH,
|
root: UI_PATH,
|
||||||
verbose: false
|
verbose: false
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ const production = {
|
|||||||
inject: false,
|
inject: false,
|
||||||
chunks: CHUNKS,
|
chunks: CHUNKS,
|
||||||
chunksSortMode: chunk => chunk.names[0] === 'vendor' ? -1 : 1
|
chunksSortMode: chunk => chunk.names[0] === 'vendor' ? -1 : 1
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
'NODE_ENV': JSON.stringify('production')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,14 +3,21 @@ const path = require('path');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
|
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
|
||||||
|
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
|
||||||
|
|
||||||
const TARGET_PORT = _.get(process.env, 'npm_package_config_django_port', 8043);
|
const TARGET_PORT = _.get(process.env, 'npm_package_config_django_port', 8043);
|
||||||
const TARGET_HOST = _.get(process.env, 'npm_package_config_django_host', 'https://localhost');
|
const TARGET_HOST = _.get(process.env, 'npm_package_config_django_host', 'https://localhost');
|
||||||
const TARGET = `https://${TARGET_HOST}:${TARGET_PORT}`;
|
const TARGET = `https://${TARGET_HOST}:${TARGET_PORT}`;
|
||||||
|
const OUTPUT = 'js/[name].js';
|
||||||
|
|
||||||
const development = require('./webpack.development');
|
const development = require('./webpack.development');
|
||||||
|
|
||||||
const watch = {
|
const watch = {
|
||||||
|
cache: true,
|
||||||
|
devtool: 'cheap-source-map',
|
||||||
|
output: {
|
||||||
|
filename: OUTPUT
|
||||||
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@@ -22,10 +29,24 @@ const watch = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new HardSourceWebpackPlugin({
|
||||||
|
cacheDirectory: 'node_modules/.cache/hard-source/[confighash]',
|
||||||
|
recordsPath: 'node_modules/.cache/hard-source/[confighash]/records.json',
|
||||||
|
configHash: config => {
|
||||||
|
return require('node-object-hash')({ sort: false }).hash(config);
|
||||||
|
},
|
||||||
|
environmentHash: {
|
||||||
|
root: process.cwd(),
|
||||||
|
directories: ['node_modules'],
|
||||||
|
files: ['package.json']
|
||||||
|
}
|
||||||
|
}),
|
||||||
new HtmlWebpackHarddiskPlugin(),
|
new HtmlWebpackHarddiskPlugin(),
|
||||||
new webpack.HotModuleReplacementPlugin()
|
new webpack.HotModuleReplacementPlugin()
|
||||||
],
|
],
|
||||||
devServer: {
|
devServer: {
|
||||||
|
hot: true,
|
||||||
|
inline: true,
|
||||||
contentBase: path.resolve(__dirname, '..', 'static'),
|
contentBase: path.resolve(__dirname, '..', 'static'),
|
||||||
stats: 'minimal',
|
stats: 'minimal',
|
||||||
publicPath: '/static/',
|
publicPath: '/static/',
|
||||||
@@ -35,7 +56,8 @@ const watch = {
|
|||||||
'/': {
|
'/': {
|
||||||
target: TARGET,
|
target: TARGET,
|
||||||
secure: false,
|
secure: false,
|
||||||
ws: false
|
ws: false,
|
||||||
|
bypass: req => req.originalUrl.includes('hot-update.json')
|
||||||
},
|
},
|
||||||
'/websocket': {
|
'/websocket': {
|
||||||
target: TARGET,
|
target: TARGET,
|
||||||
@@ -50,4 +72,3 @@ watch.module.rules = development.module.rules.concat(watch.module.rules);
|
|||||||
watch.plugins = development.plugins.concat(watch.plugins);
|
watch.plugins = development.plugins.concat(watch.plugins);
|
||||||
|
|
||||||
module.exports = _.merge(development, watch);
|
module.exports = _.merge(development, watch);
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
"grunt-concurrent": "^2.3.0",
|
"grunt-concurrent": "^2.3.0",
|
||||||
"grunt-contrib-jshint": "^1.0.0",
|
"grunt-contrib-jshint": "^1.0.0",
|
||||||
"grunt-newer": "^1.2.0",
|
"grunt-newer": "^1.2.0",
|
||||||
|
"hard-source-webpack-plugin": "^0.4.9",
|
||||||
"html-loader": "^0.5.1",
|
"html-loader": "^0.5.1",
|
||||||
"html-webpack-harddisk-plugin": "^0.1.0",
|
"html-webpack-harddisk-plugin": "^0.1.0",
|
||||||
"html-webpack-plugin": "^2.30.1",
|
"html-webpack-plugin": "^2.30.1",
|
||||||
@@ -79,9 +80,8 @@
|
|||||||
"load-grunt-tasks": "^3.5.0",
|
"load-grunt-tasks": "^3.5.0",
|
||||||
"ngtemplate-loader": "^2.0.1",
|
"ngtemplate-loader": "^2.0.1",
|
||||||
"nightwatch": "^0.9.16",
|
"nightwatch": "^0.9.16",
|
||||||
|
"node-object-hash": "^1.3.0",
|
||||||
"phantomjs-prebuilt": "^2.1.12",
|
"phantomjs-prebuilt": "^2.1.12",
|
||||||
"script-loader": "^0.7.0",
|
|
||||||
"style-loader": "^0.18.2",
|
|
||||||
"time-grunt": "^1.4.0",
|
"time-grunt": "^1.4.0",
|
||||||
"uglifyjs-webpack-plugin": "^0.4.6",
|
"uglifyjs-webpack-plugin": "^0.4.6",
|
||||||
"webpack": "^3.0.0",
|
"webpack": "^3.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user