Hello,
I have this problem, I made a custom entry for my Webpack.
The Webpack file and the one that is installed by default with sage, I just added the object config.entry.
'use strict'; // eslint-disable-line
const webpack = require('webpack');
const merge = require('webpack-merge');
const CleanPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
//const StyleLintPlugin = require('stylelint-webpack-plugin');
const CopyGlobsPlugin = require('copy-globs-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const desire = require('./util/desire');
const config = require('./config');
config.entry = {
main: [
'./scripts/main.js',
'./styles/main.scss'
],
_awards: [
'./styles/components/_awards.scss',
'./scripts/components/_awards.js',
],
grid: [
'./styles/components/_grid.scss'
]
}
const assetsFilenames = (config.enabled.cacheBusting) ? config.cacheBusting : '[name]';
let webpackConfig = {
context: config.paths.assets,
entry: config.entry,
devtool: (config.enabled.sourceMaps ? '#source-map' : undefined),
output: {
path: config.paths.dist,
publicPath: config.publicPath,
filename: `scripts/${assetsFilenames}.js`,
},
........
as you can see it generates a css file for each element of the config.entry object, so css for main, awards, and grid, the problem is for javascritp, because I should have the javascritp file only for main and awards, but for some reason it also generates a javascritp file for grid and inside the file there is this
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/app/themes/test/dist/",n(n.s=55)}({55:function(t,e,n){t.exports=n(56)},56:function(t,e){}});
How can I tell webpack that I only need the files that I have inside the config.entry?