nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit b7be554950ee05abaa5c0efdde40b1975ac742b6
parent a9d2c08cdb9125340bbb8d65273f861576f2ed9c
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Thu,  5 Dec 2019 23:59:37 +0100

config: explicitly specify dependencies to process with babel

Diffstat:
Mwebpack/webpack.config.js | 24+++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js @@ -4,6 +4,8 @@ const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const StyleLintPlugin = require('stylelint-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const fs = require('fs'); +const path = require('path'); const paths = require('./paths'); @@ -21,6 +23,24 @@ if (!envs[mode]) { const isProduction = mode === 'production'; +function dependenciesPaths() { + const blackList = ['core-js', 'regenerator-runtime']; + const paths = []; + const package_json_path = path.resolve(__dirname, '../package.json'); + const package_json = JSON.parse(fs.readFileSync(package_json_path)); + for (let dependency in package_json.dependencies) { + if (blackList.includes(dependency)) { + continue; + } + const depPath = path.resolve(__dirname, '../node_modules', dependency); + if (!fs.existsSync(depPath)) { + throw new Error(`Dependency ${dependency} not found at path ${depPath}`); + } + paths.push(depPath); + } + return paths; +} + const productionOutput = { path: paths.appBuild, filename: 'static/js/[name].[contenthash:8].js' @@ -138,9 +158,7 @@ const loaders = [ { test: /\.js$/, - exclude: [ - /node_modules\/css-loader/ - ], + include: [paths.appSrc].concat(isProduction ? dependenciesPaths() : []), loaders: [ cacheLoader, {