|
| 1 | +/** |
| 2 | + * 2007-2019 Frédéric BENOIST |
| 3 | + * |
| 4 | + * NOTICE OF LICENSE |
| 5 | + * |
| 6 | + * This source file is subject to the Academic Free License (AFL 3.0) |
| 7 | + * that is bundled with this package in the file LICENSE.txt. |
| 8 | + * It is also available through the world-wide-web at this URL: |
| 9 | + * http://opensource.org/licenses/afl-3.0.php |
| 10 | + * If you did not receive a copy of the license and are unable to |
| 11 | + * obtain it through the world-wide-web, please send an email |
| 12 | + * to [email protected] so we can send you a copy immediately. |
| 13 | + * |
| 14 | + * DISCLAIMER |
| 15 | + * |
| 16 | + * Do not edit or add to this file if you wish to upgrade PrestaShop to newer |
| 17 | + * versions in the future. If you wish to customize PrestaShop for your |
| 18 | + * needs please refer to http://www.prestashop.com for more information. |
| 19 | + * |
| 20 | + * @author Frédéric BENOIST |
| 21 | + * @copyright 2013-2019 Frédéric BENOIST <https://www.fbenoist.com/> |
| 22 | + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) |
| 23 | + */ |
| 24 | + |
| 25 | +const webpack = require('webpack'); |
| 26 | +const path = require('path'); |
| 27 | +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
| 28 | +const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); |
| 29 | +// Fix main.js (https://github.com/webpack-contrib/mini-css-extract-plugin/issues/151) |
| 30 | +const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries"); |
| 31 | + |
| 32 | +const devMode = process.argv.indexOf('development') !== -1; // In development mode ? |
| 33 | + |
| 34 | +let css_config = { |
| 35 | + entry: './css/theme.scss', |
| 36 | + output: { |
| 37 | + path: path.resolve(__dirname, '../../assets/css'), |
| 38 | + }, |
| 39 | + devtool: devMode ? 'source-map' : '', |
| 40 | + module: { |
| 41 | + rules: [ |
| 42 | + { |
| 43 | + test: /\.scss$/, |
| 44 | + use: [ |
| 45 | + { |
| 46 | + loader: MiniCssExtractPlugin.loader |
| 47 | + }, |
| 48 | + { |
| 49 | + loader: 'css-loader' |
| 50 | + }, |
| 51 | + { |
| 52 | + loader: 'postcss-loader', |
| 53 | + options: { ident: 'postcss' } |
| 54 | + }, |
| 55 | + { |
| 56 | + loader: 'sass-loader' |
| 57 | + } |
| 58 | + // Note that the loaders are ordered from bottom to top or right to left. |
| 59 | + // Loaders act like functions, that’s why it’s from right to left. |
| 60 | + // For example, css-loader(postcss-loader(sass-loader(resource))) |
| 61 | + ] |
| 62 | + }, |
| 63 | + { |
| 64 | + test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, |
| 65 | + use: [ |
| 66 | + { |
| 67 | + loader: 'file-loader', |
| 68 | + options: { |
| 69 | + name: '../css/[hash].[ext]' |
| 70 | + } |
| 71 | + } |
| 72 | + ] |
| 73 | + }, |
| 74 | + ] |
| 75 | + }, |
| 76 | + optimization: {}, |
| 77 | + plugins: [ |
| 78 | + new FixStyleOnlyEntriesPlugin(), |
| 79 | + new MiniCssExtractPlugin({ |
| 80 | + filename: 'theme.css', |
| 81 | + }), |
| 82 | + new webpack.optimize.LimitChunkCountPlugin({ |
| 83 | + maxChunks: 1, |
| 84 | + }), |
| 85 | + ], |
| 86 | +}; |
| 87 | + |
| 88 | +if (!devMode) { |
| 89 | + css_config.optimization.minimizer = [ |
| 90 | + new OptimizeCSSAssetsPlugin() |
| 91 | + ]; |
| 92 | +} |
| 93 | + |
| 94 | +module.exports = css_config; |
0 commit comments