From 7ab27bb149313dfd0eaaca09a9cb3f26f7af2482 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sun, 28 Aug 2016 20:49:25 +0300 Subject: [PATCH] Allow importing static file outside src and node_modules folders (#504) Remove the `include` setting from webpack loaders for CSS, JSON and other static assets. This way it's possible to import files from a separate config folder, a parent directory etc. --- config/webpack.config.dev.js | 4 ---- config/webpack.config.prod.js | 4 ---- 2 files changed, 8 deletions(-) diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index c652298a4fc..6a23f99f200 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -113,14 +113,12 @@ module.exports = { // in development "style" loader enables hot editing of CSS. { test: /\.css$/, - include: [paths.appSrc, paths.appNodeModules], loader: 'style!css!postcss' }, // JSON is not enabled by default in Webpack but both Node and Browserify // allow it implicitly so we also enable it. { test: /\.json$/, - include: [paths.appSrc, paths.appNodeModules], loader: 'json' }, // "file" loader makes sure those assets get served by WebpackDevServer. @@ -128,7 +126,6 @@ module.exports = { // In production, they would get copied to the `build` folder. { test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, - include: [paths.appSrc, paths.appNodeModules], exclude: /\/favicon.ico$/, loader: 'file', query: { @@ -148,7 +145,6 @@ module.exports = { // assets smaller than specified size as data URLs to avoid requests. { test: /\.(mp4|webm)(\?.*)?$/, - include: [paths.appSrc, paths.appNodeModules], loader: 'url', query: { limit: 10000, diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index 6e6d08d2d9c..a4598282577 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -115,7 +115,6 @@ module.exports = { // in the main CSS file. { test: /\.css$/, - include: [paths.appSrc, paths.appNodeModules], // "?-autoprefixer" disables autoprefixer in css-loader itself: // https://github.com/webpack/css-loader/issues/281 // We already have it thanks to postcss. We only pass this flag in @@ -131,7 +130,6 @@ module.exports = { // allow it implicitly so we also enable it. { test: /\.json$/, - include: [paths.appSrc, paths.appNodeModules], loader: 'json' }, // "file" loader makes sure those assets end up in the `build` folder. @@ -139,7 +137,6 @@ module.exports = { { test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, exclude: /\/favicon.ico$/, - include: [paths.appSrc, paths.appNodeModules], loader: 'file', query: { name: 'static/media/[name].[hash:8].[ext]' @@ -158,7 +155,6 @@ module.exports = { // assets smaller than specified size as data URLs to avoid requests. { test: /\.(mp4|webm)(\?.*)?$/, - include: [paths.appSrc, paths.appNodeModules], loader: 'url', query: { limit: 10000,