From fd41c2d2462f46febb707d7d64f9b19b5a147e39 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 26 Jul 2016 20:48:44 +0200 Subject: [PATCH] Add support for a static folder It is a nice escape hatch, ref: #28 --- config/paths.js | 3 +++ config/webpack.config.dev.js | 4 ++++ config/webpack.config.prod.js | 4 ++++ package.json | 1 + 4 files changed, 12 insertions(+) diff --git a/config/paths.js b/config/paths.js index b0f94588adb..2f9d303b8d5 100644 --- a/config/paths.js +++ b/config/paths.js @@ -35,6 +35,7 @@ if (isInCreateReactAppSource) { appFavicon: resolve('../template/favicon.ico'), appPackageJson: resolve('../package.json'), appSrc: resolve('../template/src'), + appStatic: resolve('../template/static'), appNodeModules: resolve('../node_modules'), ownNodeModules: resolve('../node_modules') }; @@ -46,6 +47,7 @@ if (isInCreateReactAppSource) { appFavicon: resolve('../../../favicon.ico'), appPackageJson: resolve('../../../package.json'), appSrc: resolve('../../../src'), + appStatic: resolve('../../../static'), appNodeModules: resolve('../..'), // this is empty with npm3 but node resolution searches higher anyway: ownNodeModules: resolve('../node_modules') @@ -58,6 +60,7 @@ if (isInCreateReactAppSource) { appFavicon: resolve('../favicon.ico'), appPackageJson: resolve('../package.json'), appSrc: resolve('../src'), + appStatic: resolve('../static'), appNodeModules: resolve('../node_modules'), ownNodeModules: resolve('../node_modules') }; diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index db68112c45c..6f5ece456bd 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.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 paths = require('./paths'); module.exports = { @@ -85,6 +86,9 @@ module.exports = { favicon: paths.appFavicon, }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' }), + new CopyWebpackPlugin([ + { from: paths.appStatic, to: 'static' } + ]), // Note: only CSS is currently hot reloaded new webpack.HotModuleReplacementPlugin() ] diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index 335f46dd9e4..6748a1ac581 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'); @@ -109,6 +110,9 @@ module.exports = { new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }), new webpack.optimize.OccurrenceOrderPlugin(), new webpack.optimize.DedupePlugin(), + new CopyWebpackPlugin([ + { from: paths.appStatic, to: 'static' } + ]), new webpack.optimize.UglifyJsPlugin({ compressor: { screw_ie8: true, diff --git a/package.json b/package.json index 321b19178ab..a64ab8856ec 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "babel-preset-es2016": "6.11.3", "babel-preset-react": "6.11.1", "chalk": "1.1.3", + "copy-webpack-plugin": "3.0.1", "cross-spawn": "4.0.0", "css-loader": "0.23.1", "eslint": "3.1.1",