From f38876be5f79c4582c44e0fa9d8996b142a594b9 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Thu, 19 May 2016 11:00:31 -0400 Subject: [PATCH] replace file loader with source loader --- lib/config.js | 3 +-- lib/plugins/static_plugin.js | 7 +------ package.json | 2 +- test/fixtures/static_plugins/plugin.js | 4 ++-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/config.js b/lib/config.js index 90eeb3e..9016efa 100644 --- a/lib/config.js +++ b/lib/config.js @@ -184,8 +184,7 @@ module.exports = class Config { _core: 'jade' }, { exclude: opts.ignore.map(mmToRe), - loader: 'file-loader', - query: { dumpDirs: opts.dumpDirs }, + loader: 'source-loader', _core: 'static' } ] diff --git a/lib/plugins/static_plugin.js b/lib/plugins/static_plugin.js index 9d28393..88287fc 100644 --- a/lib/plugins/static_plugin.js +++ b/lib/plugins/static_plugin.js @@ -42,12 +42,7 @@ module.exports = class StaticWebpackPlugin { /* istanbul ignore next */ if (dep.error) { return done(dep.error) } - // webpack stores this value using the relative path as a key - let relativePath = this.util.getOutputPath(f) - .replace(this.util.conf.context, '') - - // now we pull the value from the dependency using the correct key - const src = dep.assets[relativePath]._value + const src = dep._src const outputPath = this.util.getOutputPath(f) compilation.assets[outputPath] = { diff --git a/package.json b/package.json index 39ac84d..262923c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "browser-sync-webpack-plugin": "^1.0.1", "cheerio": "^0.20.0", "css-loader": "^0.23.1", - "file-loader": "static-dev/file-loader", "glob": "^7.0.3", "hygienist-middleware": "^0.1.1", "jade": "^1.11.0", @@ -30,6 +29,7 @@ "postcss-loader": "^0.9.1", "require-from-string": "^1.2.0", "rimraf": "^2.5.2", + "source-loader": "^0.1.0", "sprout": "^1.2.0", "webpack": "^1.13.0", "when": "^3.7.7" diff --git a/test/fixtures/static_plugins/plugin.js b/test/fixtures/static_plugins/plugin.js index 1c67eab..9f7998f 100644 --- a/test/fixtures/static_plugins/plugin.js +++ b/test/fixtures/static_plugins/plugin.js @@ -11,9 +11,9 @@ module.exports = class GladePlugin { const dep = compilation.modules.find((el) => { if (el.userRequest === f) { return el } }) - let src = String(dep.assets['foo.glade']._value) + let src = String(dep._src) src = src.replace(/glade/, 'Glade Air Freshenerâ„¢') - dep.assets['foo.glade']._value = Buffer(src) + dep._src = Buffer(src) }) done() })