Skip to content

Commit

Permalink
Allow importing static file outside src and node_modules folders (fac…
Browse files Browse the repository at this point in the history
…ebook#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.
  • Loading branch information
fson authored and George Czabania committed Sep 7, 2016
1 parent 2e01c31 commit 7ab27bb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
4 changes: 0 additions & 4 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,19 @@ 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.
// When you `import` an asset, you get its (virtual) filename.
// 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: {
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -131,15 +130,13 @@ 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.
// When you `import` an asset, you get its filename.
{
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]'
Expand All @@ -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,
Expand Down

0 comments on commit 7ab27bb

Please sign in to comment.