Include all image files by default

master
James Curtin 5 years ago committed by James Curtin
parent 1ba71a7279
commit 2764d2eba4
  1. BIN
      {{cookiecutter.app_name}}/assets/img/favicon.ico
  2. 6
      {{cookiecutter.app_name}}/assets/js/main.js
  3. 8
      {{cookiecutter.app_name}}/package.json
  4. 41
      {{cookiecutter.app_name}}/webpack.config.js
  5. 5
      {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/templates/layout.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

@ -10,6 +10,12 @@ require('jquery');
require('popper.js'); require('popper.js');
require('bootstrap'); require('bootstrap');
require.context(
"../img", // context folder
true, // include subdirectories
/.*/ // RegExp
)
// Your own code // Your own code
require('./plugins.js'); require('./plugins.js');
require('./script.js'); require('./script.js');

@ -37,16 +37,16 @@
"babel-preset-env": "^1.7.0", "babel-preset-env": "^1.7.0",
"concurrently": "^5.0.0", "concurrently": "^5.0.0",
"css-loader": "^3.0.0", "css-loader": "^3.0.0",
"eslint": "^6.2.2",
"eslint-config-airbnb-base": "^14.0.0", "eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.17.3", "eslint-plugin-import": "^2.17.3",
"eslint": "^6.2.2",
"file-loader": "^4.0.0", "file-loader": "^4.0.0",
"less-loader": "^5.0.0",
"less": "^3.9.0", "less": "^3.9.0",
"less-loader": "^5.0.0",
"mini-css-extract-plugin": "^0.8.0", "mini-css-extract-plugin": "^0.8.0",
"raw-loader": "^3.0.0", "raw-loader": "^3.0.0",
"url-loader": "^2.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"
} }
} }

@ -6,9 +6,16 @@ const webpack = require('webpack');
*/ */
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// take debug mode from the environment const ProductionPlugins = [
const debug = (process.env.NODE_ENV !== 'production'); // 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'); const rootAssetPath = path.join(__dirname, 'assets');
module.exports = { module.exports = {
@ -22,16 +29,21 @@ module.exports = {
path.join(__dirname, 'assets', 'css', 'style.css'), path.join(__dirname, 'assets', 'css', 'style.css'),
], ],
}, },
mode: debug,
output: { output: {
chunkFilename: "[id].js",
filename: "[name].bundle.js",
path: path.join(__dirname, "{{cookiecutter.app_name}}", "static", "build"), path: path.join(__dirname, "{{cookiecutter.app_name}}", "static", "build"),
publicPath: "/static/build/", publicPath: "/static/build/"
filename: "[name].js",
chunkFilename: "[id].js"
}, },
resolve: { resolve: {
extensions: [".js", ".jsx", ".css"] 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: { module: {
rules: [ rules: [
{ {
@ -66,20 +78,5 @@ module.exports = {
}, },
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['env'], cacheDirectory: true } }, { 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")
}
})
]
)
}; };

@ -10,6 +10,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="shortcut icon" href="{{static_url_for('static', filename='build/img/favicon.ico') }}">
<title> <title>
{% block page_title %} {% endraw %} {% block page_title %} {% endraw %}
{{ cookiecutter.project_name }} {{ cookiecutter.project_name }}
@ -27,7 +28,7 @@
<link <link
rel="stylesheet" rel="stylesheet"
type="text/css" 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 %} {% block css %}{% endblock %}
@ -61,7 +62,7 @@
{% include "footer.html" %} {% include "footer.html" %}
<!-- JavaScript at the bottom for fast page loading --> <!-- 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 %} {% block js %}{% endblock %}
<!-- end scripts --> <!-- end scripts -->
{% endblock %} {% endblock %}

Loading…
Cancel
Save