Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add separate webpack config for production
Marcin Gębala6bf92afd602f
diff --git a/.travis.yml b/.travis.ymlindex 584e9355d9..3051a0f082 100644--- a/.travis.yml+++ b/.travis.yml@@ -21,7 +21,7 @@ install:- nvm install 6- yarn- yarn add --force node-sass # force our way around https://github.com/yarnpkg/yarn/issues/1981- - yarn run build-assets+ - yarn run build-assets:prodscript:- toxenv:diff --git a/circle.yml b/circle.ymlindex 1a131874b1..0db89c0b20 100644--- a/circle.yml+++ b/circle.yml@@ -16,7 +16,7 @@ dependencies:- yarn add --force node-sass # force our way around https://github.com/yarnpkg/yarn/issues/1981- pip install -r requirements.txtoverride:- - yarn run build-assets --production+ - yarn run build-assets:prod --production- ./manage.py collectstatic --no-input- sed -i.bak "s#'dev'#'$(git describe --tags)'#" saleor/__init__.pypost:diff --git a/docs/deploy.rst b/docs/deploy.rstindex e8cdbe3b9d..642673b7e6 100644--- a/docs/deploy.rst+++ b/docs/deploy.rst@@ -12,7 +12,7 @@ Before building the image make sure you have all of the front-end assets prepare.. code-block:: bash- $ yarn run build-assets+ $ yarn run build-assets:prod$ python manage.py collectstaticThen use Docker to build the image:diff --git a/docs/development.rst b/docs/development.rstindex e5a41cfb8c..af4f15c43c 100644--- a/docs/development.rst+++ b/docs/development.rst@@ -29,7 +29,7 @@ To run webpack in *watch* mode run:.. code-block:: bash- $ npm start+ $ yarn start.. warning::@@ -38,7 +38,7 @@ To run webpack in *watch* mode run:.. code-block:: bash- $ npm run build-assets+ $ yarn run build-assets:prodWorking with backend codediff --git a/package.json b/package.jsonindex ae605ee621..fe13df41c2 100644--- a/package.json+++ b/package.json@@ -89,6 +89,7 @@},"scripts": {"build-assets": "node ./node_modules/webpack/bin/webpack.js -p",+ "build-assets:prod": "NODE_ENV=production node ./node_modules/webpack/bin/webpack.js --config webpack.production.config.js -p","heroku-postbuild": "yarn add --force node-sass && yarn run build-assets","start": "UV_THREADPOOL_SIZE=8 node ./node_modules/webpack/bin/webpack.js -d --watch"}diff --git a/webpack.config.js b/webpack.config.jsindex 5eb5419479..5840f5f1cf 100644--- a/webpack.config.js+++ b/webpack.config.js@@ -24,6 +24,8 @@ var environmentPlugin = new webpack.DefinePlugin({}});+var uglifyJSPlugin = new webpack.optimize.UglifyJsPlugin();+var providePlugin = new webpack.ProvidePlugin({$: 'jquery','_': 'underscore',@@ -89,7 +91,8 @@ var config = {environmentPlugin,extractTextPlugin,occurenceOrderPlugin,- providePlugin+ providePlugin,+ uglifyJSPlugin],postcss: function() {return [autoprefixer];diff --git a/webpack.production.config.js b/webpack.production.config.jsnew file mode 100644index 0000000000..565f673087--- /dev/null+++ b/webpack.production.config.js@@ -0,0 +1,54 @@+var BundleTracker = require('webpack-bundle-tracker');+var ExtractTextPlugin = require('extract-text-webpack-plugin');+var path = require('path');+var webpack = require('webpack');+var config = require('./webpack.config');++var resolve = path.resolve.bind(path, __dirname);++var bundleTrackerPlugin = new BundleTracker({+ filename: 'webpack-bundle.json'+});++var commonsChunkPlugin = new webpack.optimize.CommonsChunkPlugin({+ names: 'vendor'+});++var extractTextPlugin = new ExtractTextPlugin('[name].css');++var occurenceOrderPlugin = new webpack.optimize.OccurenceOrderPlugin();++var environmentPlugin = new webpack.DefinePlugin({+ 'process.env': {+ NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')+ }+});++var uglifyJSPlugin = new webpack.optimize.UglifyJsPlugin();++var providePlugin = new webpack.ProvidePlugin({+ $: 'jquery',+ '_': 'underscore',+ jQuery: 'jquery',+ 'window.jQuery': 'jquery',+ 'Tether': 'tether',+ 'window.Tether': 'tether'+});++config.output = {+ path: resolve('saleor/static/assets/'),+ filename: '[name].js',+ publicPath: '/'+};++config.plugins = [+ bundleTrackerPlugin,+ commonsChunkPlugin,+ environmentPlugin,+ extractTextPlugin,+ occurenceOrderPlugin,+ providePlugin,+ uglifyJSPlugin+];++module.exports = config;