diff --git a/{{cookiecutter.app_name}}/assets/img/favicon.ico b/{{cookiecutter.app_name}}/assets/img/favicon.ico new file mode 100644 index 0000000..04d842c Binary files /dev/null and b/{{cookiecutter.app_name}}/assets/img/favicon.ico differ diff --git a/{{cookiecutter.app_name}}/assets/js/main.js b/{{cookiecutter.app_name}}/assets/js/main.js index cb0cc84..c3a83e2 100644 --- a/{{cookiecutter.app_name}}/assets/js/main.js +++ b/{{cookiecutter.app_name}}/assets/js/main.js @@ -10,6 +10,12 @@ require('jquery'); require('popper.js'); require('bootstrap'); +require.context( + "../img", // context folder + true, // include subdirectories + /.*/ // RegExp +) + // Your own code require('./plugins.js'); require('./script.js'); diff --git a/{{cookiecutter.app_name}}/package.json b/{{cookiecutter.app_name}}/package.json index 92a4199..aa0702b 100644 --- a/{{cookiecutter.app_name}}/package.json +++ b/{{cookiecutter.app_name}}/package.json @@ -37,16 +37,16 @@ "babel-preset-env": "^1.7.0", "concurrently": "^5.0.0", "css-loader": "^3.0.0", + "eslint": "^6.2.2", "eslint-config-airbnb-base": "^14.0.0", "eslint-plugin-import": "^2.17.3", - "eslint": "^6.2.2", "file-loader": "^4.0.0", - "less-loader": "^5.0.0", "less": "^3.9.0", + "less-loader": "^5.0.0", "mini-css-extract-plugin": "^0.8.0", "raw-loader": "^3.0.0", "url-loader": "^2.0.0", - "webpack-cli": "^3.3.2", - "webpack": "^4.33.0" + "webpack": "^4.33.0", + "webpack-cli": "^3.3.2" } } diff --git a/{{cookiecutter.app_name}}/webpack.config.js b/{{cookiecutter.app_name}}/webpack.config.js index 74eee16..8647130 100644 --- a/{{cookiecutter.app_name}}/webpack.config.js +++ b/{{cookiecutter.app_name}}/webpack.config.js @@ -6,9 +6,16 @@ const webpack = require('webpack'); */ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -// take debug mode from the environment -const debug = (process.env.NODE_ENV !== 'production'); +const ProductionPlugins = [ + // production webpack plugins go here + new webpack.DefinePlugin({ + "process.env": { + NODE_ENV: JSON.stringify("production") + } + }) +] +const debug = (process.env.NODE_ENV !== 'production'); const rootAssetPath = path.join(__dirname, 'assets'); module.exports = { @@ -22,16 +29,21 @@ module.exports = { path.join(__dirname, 'assets', 'css', 'style.css'), ], }, + mode: debug, output: { + chunkFilename: "[id].js", + filename: "[name].bundle.js", path: path.join(__dirname, "{{cookiecutter.app_name}}", "static", "build"), - publicPath: "/static/build/", - filename: "[name].js", - chunkFilename: "[id].js" + publicPath: "/static/build/" }, resolve: { extensions: [".js", ".jsx", ".css"] }, - devtool: "source-map", + devtool: debug ? "eval-source-map" : null, + plugins: [ + new MiniCssExtractPlugin({ filename: "[name].bundle.css" }), + new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) + ].concat(debug ? [] : ProductionPlugins), module: { rules: [ { @@ -66,20 +78,5 @@ module.exports = { }, { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['env'], cacheDirectory: true } }, ], - }, - plugins: [ - new MiniCssExtractPlugin({ filename: "[name].css" }), - new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) - ].concat( - debug - ? [] - : [ - // production webpack plugins go here - new webpack.DefinePlugin({ - "process.env": { - NODE_ENV: JSON.stringify("production") - } - }) - ] - ) + } }; diff --git a/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/templates/layout.html b/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/templates/layout.html index 1df7a39..7e8a3d5 100644 --- a/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/templates/layout.html +++ b/{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/templates/layout.html @@ -10,6 +10,7 @@ + {% block page_title %} {% endraw %} {{ cookiecutter.project_name }} @@ -27,7 +28,7 @@ <link rel="stylesheet" type="text/css" - href="{{ static_url_for('static', filename='build/main_css.css') }}" + href="{{ static_url_for('static', filename='build/main_css.bundle.css') }}" /> {% block css %}{% endblock %} @@ -61,7 +62,7 @@ {% include "footer.html" %} <!-- JavaScript at the bottom for fast page loading --> - <script src="{{ static_url_for('static', filename='build/main_js.js') }}"></script> + <script src="{{ static_url_for('static', filename='build/main_js.bundle.js') }}"></script> {% block js %}{% endblock %} <!-- end scripts --> {% endblock %}