Commit c27570ed authored by Ville Immonen's avatar Ville Immonen Committed by Dan Abramov
Browse files

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.
parent 73c940a7
Showing with 0 additions and 8 deletions
+0 -8
...@@ -112,14 +112,12 @@ module.exports = { ...@@ -112,14 +112,12 @@ module.exports = {
// in development "style" loader enables hot editing of CSS. // in development "style" loader enables hot editing of CSS.
{ {
test: /\.css$/, test: /\.css$/,
include: [paths.appSrc, paths.appNodeModules],
loader: 'style!css!postcss' loader: 'style!css!postcss'
}, },
// JSON is not enabled by default in Webpack but both Node and Browserify // JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it. // allow it implicitly so we also enable it.
{ {
test: /\.json$/, test: /\.json$/,
include: [paths.appSrc, paths.appNodeModules],
loader: 'json' loader: 'json'
}, },
// "file" loader makes sure those assets get served by WebpackDevServer. // "file" loader makes sure those assets get served by WebpackDevServer.
...@@ -127,7 +125,6 @@ module.exports = { ...@@ -127,7 +125,6 @@ module.exports = {
// In production, they would get copied to the `build` folder. // In production, they would get copied to the `build` folder.
{ {
test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
include: [paths.appSrc, paths.appNodeModules],
exclude: /\/favicon.ico$/, exclude: /\/favicon.ico$/,
loader: 'file', loader: 'file',
query: { query: {
...@@ -147,7 +144,6 @@ module.exports = { ...@@ -147,7 +144,6 @@ module.exports = {
// assets smaller than specified size as data URLs to avoid requests. // assets smaller than specified size as data URLs to avoid requests.
{ {
test: /\.(mp4|webm)(\?.*)?$/, test: /\.(mp4|webm)(\?.*)?$/,
include: [paths.appSrc, paths.appNodeModules],
loader: 'url', loader: 'url',
query: { query: {
limit: 10000, limit: 10000,
......
...@@ -114,7 +114,6 @@ module.exports = { ...@@ -114,7 +114,6 @@ module.exports = {
// in the main CSS file. // in the main CSS file.
{ {
test: /\.css$/, test: /\.css$/,
include: [paths.appSrc, paths.appNodeModules],
// "?-autoprefixer" disables autoprefixer in css-loader itself: // "?-autoprefixer" disables autoprefixer in css-loader itself:
// https://github.com/webpack/css-loader/issues/281 // https://github.com/webpack/css-loader/issues/281
// We already have it thanks to postcss. We only pass this flag in // We already have it thanks to postcss. We only pass this flag in
...@@ -130,7 +129,6 @@ module.exports = { ...@@ -130,7 +129,6 @@ module.exports = {
// allow it implicitly so we also enable it. // allow it implicitly so we also enable it.
{ {
test: /\.json$/, test: /\.json$/,
include: [paths.appSrc, paths.appNodeModules],
loader: 'json' loader: 'json'
}, },
// "file" loader makes sure those assets end up in the `build` folder. // "file" loader makes sure those assets end up in the `build` folder.
...@@ -138,7 +136,6 @@ module.exports = { ...@@ -138,7 +136,6 @@ module.exports = {
{ {
test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
exclude: /\/favicon.ico$/, exclude: /\/favicon.ico$/,
include: [paths.appSrc, paths.appNodeModules],
loader: 'file', loader: 'file',
query: { query: {
name: 'static/media/[name].[hash:8].[ext]' name: 'static/media/[name].[hash:8].[ext]'
...@@ -157,7 +154,6 @@ module.exports = { ...@@ -157,7 +154,6 @@ module.exports = {
// assets smaller than specified size as data URLs to avoid requests. // assets smaller than specified size as data URLs to avoid requests.
{ {
test: /\.(mp4|webm)(\?.*)?$/, test: /\.(mp4|webm)(\?.*)?$/,
include: [paths.appSrc, paths.appNodeModules],
loader: 'url', loader: 'url',
query: { query: {
limit: 10000, limit: 10000,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment