nl_tokens: Return a webpack config object
pl_tokens: function getWebpackConfig ( env = { } , // eslint-disable-line no-unused-vars { entry , 'output-chunk-filename' : outputChunkFilename , 'output-path' : outputPath = path . join ( process . cwd ( ) , 'dist' ) , 'output-filename' : outputFilename = '[name].js' , 'output-libary-target' : outputLibraryTarget = 'window' , } ) { const workerCount = 1 ; const cssFilename = cssNameFromFilename ( outputFilename ) ; const cssChunkFilename = cssNameFromFilename ( outputChunkFilename ) ; let babelConfig = path . join ( process . cwd ( ) , 'babel.config.js' ) ; let presets = [ ] ; if ( ! fs . existsSync ( babelConfig ) ) { // Default to this package's Babel presets presets = [ path . join ( __dirname , 'babel' , 'default' ) , env . WP && path . join ( __dirname , 'babel' , 'wordpress-element' ) , ] . filter ( Boolean ) ; babelConfig = undefined ; } const webpackConfig = { bail : ! isDevelopment , entry , <mask> : isDevelopment ? 'development' : 'production' , devtool : process . env . SOURCEMAP || ( isDevelopment ? '#eval' : false ) , output : { chunkFilename : outputChunkFilename , path : outputPath , filename : outputFilename , libraryTarget : outputLibraryTarget , } , optimization : { minimize : ! isDevelopment , minimizer : Minify ( { cache : process . env . CIRCLECI ? ` ${ process . env . HOME } ` : 'docker' !== process . env . CONTAINER , parallel : workerCount , sourceMap : Boolean ( process . env . SOURCEMAP ) , terserOptions : { ecma : 5 , safari10 : true , mangle : true , } , } ) , } , module : { rules : [ TranspileConfig . loader ( { cacheDirectory : true , configFile : babelConfig , exclude : / node_modules\/ / , presets , workerCount , } ) , SassConfig . loader ( { preserveCssCustomProperties : false , prelude : '@import "~@automattic/calypso-color-schemes/src/shared/colors";' , } ) , FileConfig . loader ( ) , ] , } , resolve : { extensions : [ '.json' , '.js' , '.jsx' , '.ts' , '.tsx' ] , modules : [ 'node_modules' ] , } , node : false , plugins : [ new webpack . DefinePlugin ( { 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) , global : 'window' , } ) , new webpack . IgnorePlugin ( / ^\.\/locale$ / , / moment$ / ) , ... SassConfig . plugins ( { chunkFilename : cssChunkFilename , filename : cssFilename , minify : ! isDevelopment , } ) , new DuplicatePackageCheckerPlugin ( ) , ... ( env . WP ? [ new WordPressExternalDependenciesPlugin ( ) ] : [ ] ) , ] , } ; return webpackConfig ; }