Skip to content

Commit 7ab27bb

Browse files
fsonGeorge Czabania
authored and
George Czabania
committed
Allow importing static file outside src and node_modules folders (facebook#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 2e01c31 commit 7ab27bb

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
@@ -113,22 +113,19 @@ module.exports = {
113113
// in development "style" loader enables hot editing of CSS.
114114
{
115115
test: /\.css$/,
116-
include: [paths.appSrc, paths.appNodeModules],
117116
loader: 'style!css!postcss'
118117
},
119118
// JSON is not enabled by default in Webpack but both Node and Browserify
120119
// allow it implicitly so we also enable it.
121120
{
122121
test: /\.json$/,
123-
include: [paths.appSrc, paths.appNodeModules],
124122
loader: 'json'
125123
},
126124
// "file" loader makes sure those assets get served by WebpackDevServer.
127125
// When you `import` an asset, you get its (virtual) filename.
128126
// In production, they would get copied to the `build` folder.
129127
{
130128
test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
131-
include: [paths.appSrc, paths.appNodeModules],
132129
exclude: /\/favicon.ico$/,
133130
loader: 'file',
134131
query: {
@@ -148,7 +145,6 @@ module.exports = {
148145
// assets smaller than specified size as data URLs to avoid requests.
149146
{
150147
test: /\.(mp4|webm)(\?.*)?$/,
151-
include: [paths.appSrc, paths.appNodeModules],
152148
loader: 'url',
153149
query: {
154150
limit: 10000,

config/webpack.config.prod.js

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

0 commit comments

Comments
 (0)