Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Drop separate configs; use NODE_ENV for different production settings

Marcin Gębala32e6a00d09a4
diff --git a/.travis.yml b/.travis.yml
index 3051a0f082..5ac938807a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,9 +19,9 @@ install:
- pip install -U pip setuptools wheel
- pip install tox codecov
- nvm install 6
- - yarn
+ - yarn install --production
- yarn add --force node-sass # force our way around https://github.com/yarnpkg/yarn/issues/1981
- - yarn run build-assets:prod
+ - yarn run build-assets --production
script:
- tox
env:
diff --git a/circle.yml b/circle.yml
index 0db89c0b20..0aeaa864c3 100644
--- a/circle.yml
+++ b/circle.yml
@@ -12,11 +12,11 @@ machine:
dependencies:
pre:
- - yarn
+ - yarn install --production
- yarn add --force node-sass # force our way around https://github.com/yarnpkg/yarn/issues/1981
- pip install -r requirements.txt
override:
- - yarn run build-assets:prod --production
+ - yarn run build-assets --production
- ./manage.py collectstatic --no-input
- sed -i.bak "s#'dev'#'$(git describe --tags)'#" saleor/__init__.py
post:
diff --git a/docs/deploy.rst b/docs/deploy.rst
index 642673b7e6..10d1f1b98b 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:prod
+ $ yarn run build-assets --production
$ python manage.py collectstatic
Then use Docker to build the image:
diff --git a/docs/development.rst b/docs/development.rst
index af4f15c43c..ad1052f599 100644
--- a/docs/development.rst
+++ b/docs/development.rst
@@ -38,7 +38,7 @@ To run webpack in *watch* mode run:
.. code-block:: bash
- $ yarn run build-assets:prod
+ $ yarn run build-assets --production
Working with backend code
diff --git a/package.json b/package.json
index df099d4828..1c04687132 100644
--- a/package.json
+++ b/package.json
@@ -88,8 +88,7 @@
}
},
"scripts": {
- "build-assets": "node ./node_modules/webpack/bin/webpack.js -d",
- "build-assets:prod": "NODE_ENV=production node ./node_modules/webpack/bin/webpack.js --config webpack.production.config.js -p",
+ "build-assets": "node ./node_modules/webpack/bin/webpack.js",
"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.js
index 83dee9cd45..2c8bfaf9b1 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -6,6 +6,25 @@ var webpack = require('webpack');
var resolve = path.resolve.bind(path, __dirname);
+var output;
+var extractTextPlugin;
+
+if (process.env.NODE_ENV === 'production') {
+ output = {
+ path: resolve('saleor/static/assets/'),
+ filename: '[name].[chunkhash].js',
+ publicPath: '/'
+ };
+ extractTextPlugin = new ExtractTextPlugin('[name].[contenthash].css');
+} else {
+ output = {
+ path: resolve('saleor/static/assets/'),
+ filename: '[name].js',
+ publicPath: '/static/assets/'
+ };
+ extractTextPlugin = new ExtractTextPlugin('[name].css');
+}
+
var bundleTrackerPlugin = new BundleTracker({
filename: 'webpack-bundle.json'
});
@@ -16,8 +35,6 @@ var commonsChunkPlugin = new webpack.optimize.CommonsChunkPlugin({
var occurenceOrderPlugin = new webpack.optimize.OccurenceOrderPlugin();
-var extractTextPlugin = new ExtractTextPlugin('[name].css');
-
var environmentPlugin = new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
@@ -47,11 +64,7 @@ var config = {
'react-relay'
]
},
- output: {
- path: resolve('saleor/static/assets/'),
- filename: '[name].js',
- publicPath: '/static/assets/'
- },
+ output: output,
module: {
loaders: [
{
diff --git a/webpack.production.config.js b/webpack.production.config.js
deleted file mode 100644
index 1ec8f0638e..0000000000
--- a/webpack.production.config.js
+++ /dev/null
@@ -1,51 +0,0 @@
-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].[contenthash].css');
-
-var occurenceOrderPlugin = new webpack.optimize.OccurenceOrderPlugin();
-
-var environmentPlugin = new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
- }
-});
-
-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].[chunkhash].js',
- publicPath: '/'
-};
-
-config.plugins = [
- bundleTrackerPlugin,
- commonsChunkPlugin,
- environmentPlugin,
- extractTextPlugin,
- occurenceOrderPlugin,
- providePlugin
-];
-
-module.exports = config;