Skip to content

Commit c27570e

Browse files
fsongaearon
authored andcommitted
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.
1 parent 73c940a commit c27570e

File tree

2 files changed

+0
-8
lines changed

2 files changed

+0
-8
lines changed

config/webpack.config.dev.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,19 @@ module.exports = {
112112
// in development "style" loader enables hot editing of CSS.
113113
{
114114
test: /\.css$/,
115-
include: [paths.appSrc, paths.appNodeModules],
116115
loader: 'style!css!postcss'
117116
},
118117
// JSON is not enabled by default in Webpack but both Node and Browserify
119118
// allow it implicitly so we also enable it.
120119
{
121120
test: /\.json$/,
122-
include: [paths.appSrc, paths.appNodeModules],
123121
loader: 'json'
124122
},
125123
// "file" loader makes sure those assets get served by WebpackDevServer.
126124
// When you `import` an asset, you get its (virtual) filename.
127125
// In production, they would get copied to the `build` folder.
128126
{
129127
test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
130-
include: [paths.appSrc, paths.appNodeModules],
131128
exclude: /\/favicon.ico$/,
132129
loader: 'file',
133130
query: {
@@ -147,7 +144,6 @@ module.exports = {
147144
// assets smaller than specified size as data URLs to avoid requests.
148145
{
149146
test: /\.(mp4|webm)(\?.*)?$/,
150-
include: [paths.appSrc, paths.appNodeModules],
151147
loader: 'url',
152148
query: {
153149
limit: 10000,

config/webpack.config.prod.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ module.exports = {
114114
// in the main CSS file.
115115
{
116116
test: /\.css$/,
117-
include: [paths.appSrc, paths.appNodeModules],
118117
// "?-autoprefixer" disables autoprefixer in css-loader itself:
119118
// https://github.com/webpack/css-loader/issues/281
120119
// We already have it thanks to postcss. We only pass this flag in
@@ -130,15 +129,13 @@ module.exports = {
130129
// allow it implicitly so we also enable it.
131130
{
132131
test: /\.json$/,
133-
include: [paths.appSrc, paths.appNodeModules],
134132
loader: 'json'
135133
},
136134
// "file" loader makes sure those assets end up in the `build` folder.
137135
// When you `import` an asset, you get its filename.
138136
{
139137
test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
140138
exclude: /\/favicon.ico$/,
141-
include: [paths.appSrc, paths.appNodeModules],
142139
loader: 'file',
143140
query: {
144141
name: 'static/media/[name].[hash:8].[ext]'
@@ -157,7 +154,6 @@ module.exports = {
157154
// assets smaller than specified size as data URLs to avoid requests.
158155
{
159156
test: /\.(mp4|webm)(\?.*)?$/,
160-
include: [paths.appSrc, paths.appNodeModules],
161157
loader: 'url',
162158
query: {
163159
limit: 10000,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy