Skip to content

Commit

Permalink
Switch assets manifest plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t committed Nov 7, 2016
1 parent c49793c commit c1bb2b3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 123 deletions.
19 changes: 0 additions & 19 deletions assets/build/util/assetsPluginProcessOutput.js

This file was deleted.

48 changes: 40 additions & 8 deletions assets/build/webpack.config.production.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
const AssetsPlugin = require('assets-webpack-plugin');
'use strict'; // eslint-disable-line

const WebpackAssetsManifest = require('webpack-assets-manifest');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const cssnano = require('cssnano');
const path = require('path');

const processOutput = require('./util/assetsPluginProcessOutput');
const config = require('./config');

module.exports = {
plugins: [
new AssetsPlugin({
path: config.paths.dist,
filename: 'assets.json',
fullPath: false,
processOutput(assets) {
return JSON.stringify(Object.assign(processOutput(assets), config.manifest));
new WebpackAssetsManifest({
output: 'assets.json',
space: 2,
writeToDisk: false,
assets: config.manifest,
replacer(key, value) {
if (typeof value === 'string') {
return value;
}
const manifest = value;
/**
* Hack to prepend scripts/ or styles/ to manifest keys
*
* This might need to be reworked at some point.
*
* Before:
* {
* "main.js": "scripts/main_abcdef.js"
* "main.css": "styles/main_abcdef.css"
* }
* After:
* {
* "scripts/main.js": "scripts/main_abcdef.js"
* "styles/main.css": "styles/main_abcdef.css"
* }
*/
Object.keys(manifest).forEach((src) => {
const sourcePath = path.basename(path.dirname(src));
const targetPath = path.basename(path.dirname(manifest[src]));
if (sourcePath === targetPath) {
return;
}
manifest[`${targetPath}/${src}`] = manifest[src];
delete manifest[src];
});
return manifest;
},
}),
new OptimizeCssAssetsPlugin({
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"node": ">= 4.5"
},
"devDependencies": {
"assets-webpack-plugin": "^3.5.0",
"autoprefixer": "^6.5.1",
"autoprefixer": "^6.5.2",
"body-parser": "^1.15.2",
"browser-sync": "^2.17.5",
"buble": "^0.14.2",
Expand All @@ -43,7 +42,7 @@
"eslint-loader": "^1.6.1",
"eslint-plugin-import": "^2.0.1",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.5.0",
"eslint-plugin-react": "^6.6.0",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.9.0",
"glob": "^7.1.1",
Expand All @@ -65,6 +64,7 @@
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^2.1.0-beta.25",
"webpack-assets-manifest": "^0.5.0",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.1"
},
Expand Down

0 comments on commit c1bb2b3

Please sign in to comment.