diff --git a/config/paths.js b/config/paths.js index 7645917fbc..4db5873d29 100644 --- a/config/paths.js +++ b/config/paths.js @@ -38,6 +38,7 @@ if (isInCreateReactAppSource) { appHtml: resolveOwn('../template/index.html'), appFavicon: resolveOwn('../template/favicon.ico'), appPackageJson: resolveOwn('../package.json'), + appStatic: resolveOwn('../template/static'), appSrc: resolveOwn('../template/src'), appNodeModules: resolveOwn('../node_modules'), ownNodeModules: resolveOwn('../node_modules') @@ -49,6 +50,7 @@ if (isInCreateReactAppSource) { appHtml: resolveApp('index.html'), appFavicon: resolveApp('favicon.ico'), appPackageJson: resolveApp('package.json'), + appStatic: resolveApp('static'), appSrc: resolveApp('src'), appNodeModules: resolveApp('node_modules'), // this is empty with npm3 but node resolution searches higher anyway: @@ -61,6 +63,7 @@ if (isInCreateReactAppSource) { appHtml: resolveApp('index.html'), appFavicon: resolveApp('favicon.ico'), appPackageJson: resolveApp('package.json'), + appStatic: resolveApp('static'), appSrc: resolveApp('src'), appNodeModules: resolveApp('node_modules'), ownNodeModules: resolveApp('node_modules') diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index a3db11f8ec..f84cd736b6 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -13,6 +13,7 @@ var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); var WatchMissingNodeModulesPlugin = require('../scripts/utils/WatchMissingNodeModulesPlugin'); +var CopyWebpackPlugin = require('copy-webpack-plugin'); var paths = require('./paths'); var env = require('./env'); @@ -170,6 +171,10 @@ module.exports = { template: paths.appHtml, favicon: paths.appFavicon, }), + // Copy the static folder as-is to the build folder + new CopyWebpackPlugin([ + { from: paths.appStatic, to: 'static' } + ]), // Makes some environment variables available to the JS code, for example: // if (process.env.NODE_ENV === 'development') { ... }. See `env.js`. new webpack.DefinePlugin(env), diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index 2a3b1a8186..e0f010a2e0 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -11,6 +11,7 @@ var path = require('path'); var autoprefixer = require('autoprefixer'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); +var CopyWebpackPlugin = require('copy-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var url = require('url'); var paths = require('./paths'); @@ -203,6 +204,10 @@ module.exports = { new webpack.optimize.OccurrenceOrderPlugin(), // Try to dedupe duplicated modules, if any: new webpack.optimize.DedupePlugin(), + // Copy the static folder as-is to the build folder + new CopyWebpackPlugin([ + { from: paths.appStatic, to: 'static' } + ]), // Minify the code. new webpack.optimize.UglifyJsPlugin({ compress: { diff --git a/package.json b/package.json index bf3d853af2..8640effb0b 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "case-sensitive-paths-webpack-plugin": "1.1.2", "chalk": "1.1.3", "connect-history-api-fallback": "1.2.0", + "copy-webpack-plugin": "3.0.1", "cross-spawn": "4.0.0", "css-loader": "0.23.1", "detect-port": "1.0.0",