Отдельные файлы модулей узла Webpack - PullRequest
0 голосов
/ 03 февраля 2020

Я прочитал документацию. Проблема в том, что когда я использую chunking и указываю имя файла, я не могу найти файл. Из того, что я вижу, он просто увеличивает исходный файл.

Я новичок в веб-пакете.

По сути, я хочу скомпилировать и объединить модули узлов в один файл и другие файлы JavaScript в отдельные файлы.

Я понял это, но получаю ошибки в консоли. отправит asa.

enter image description here

var path = require('path');
var webpack = require('webpack');
const pkg = require('./package.json');
module.exports = function (env) {

env = env || {};
var isProd = env.NODE_ENV === 'production';

// Setup base config for all environments
var config = {
    mode: 'development',
    target: 'node',
    entry: {
        mapping: './wwwroot/js/mapping/index.js'
    },
    output: {
        path: path.resolve(__dirname, 'wwwroot/dist'),
        filename: '[name].js'
    },
    devtool: 'eval-source-map',
    resolve: {
        extensions: ['.ts', '.tsx', '.js', '.jsx']
    },
    plugins: [
        new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' })

    ],
    optimization: {
        splitChunks: {
            cacheGroups: {
                vendor: {
                    test: /[\\/]node_modules[\\/]/,
                    name: 'vendor',
                    chunks: 'all',
                }
            }
        }
    },
    module: {
        rules: [
            { test: /\.css?$/, use: ['style-loader', 'css-loader'] },
            { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' },
            { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' }
        ]
    }
}

return config;
};


{
  "name": "openlayers",
  "version": "1.0.0",
  "scripts": {
   "start": "webpack --config webpack.config.js --watch --progress --profile",
   "build": "webpack --config webpack.config.js --progress --profile",
   "prod": "webpack --env.NODE_ENV=production --config webpack.config.js    --progress"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
  "@babel/core": "^7.8.3",
  "authenticate": "^0.1.5",
  "babel-preset-es2015": "^6.24.1",
  "babel-upgrade": "^1.0.1",
  "commonjs": "0.0.1",
  "config": "^3.2.5",
  "core-js": "^3.6.4",
  "fs": "0.0.1-security",
  "jquery": "^3.4.1",
  "leaflet": "^1.6.0",
  "ol": "^5.3.3",
  "ol-contextmenu": "^3.3.2",
  "ol-hashed": "^2.0.0",
  "ol-layerswitcher": "^3.4.0",
  "proj4": "^2.6.0",
  "sidebar-v2": "^0.4.0"
 },
 "devDependencies": {
"babel-preset-env": "^1.7.0",
"parcel-bundler": "^1.12.4",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
 },
 "description": ""
}
...