ut-webpack
raw JSON → 9.1.1 verified Sat Apr 25 auth: no javascript
A Neutrino-based preset for the UT framework, providing shared Webpack configuration for building and developing frontend applications. Current stable version is 9.1.1. It simplifies setup by offering pre-configured build and dev server scripts, with options for customizing public path, source, output, proxy, CSS imports, and content security policy. Release cadence is tied to UT framework updates. Key differentiators: integrates tightly with Neutrino and UT ecosystem, supports multiple entry points (mains) out of the box.
Common errors
error Cannot find module 'neutrino' ↓
cause Neutrino is not installed as a peer dependency.
fix
Install neutrino: npm install neutrino --save-dev
error ut-webpack: command not found ↓
cause ut-webpack is not installed globally or locally in node_modules/.bin.
fix
Install globally: npm install -g ut-webpack, or use npx ut-webpack.
error TypeError: utWebpack is not a function ↓
cause utWebpack was imported incorrectly or the config file export is wrong.
fix
Ensure correct import: const utWebpack = require('ut-webpack'); and the exported function calls utWebpack as a function.
Warnings
gotcha ut-webpack must be installed globally for the CLI commands (ut-webpack, ut-webpack-dev-server) to work. ↓
fix Install globally: npm install -g ut-webpack. Alternatively, use npx or add to package.json scripts.
gotcha The configuration file must export a function, not an object, because the preset system expects a factory. ↓
fix Use: module.exports = ({utWebpack}) => ({...});
gotcha If 'cssImport' option is set, the path must exist; otherwise postcss-import will fail silently. ↓
fix Ensure the directory exists, e.g., path.resolve('impl/browser/config').
gotcha The dev server proxy context uses a negative pattern to exclude static assets; misconfiguration can cause proxy errors. ↓
fix Verify proxy context array and target URL. Default context: ['!/a/browser/**'].
Install
npm install ut-webpack yarn add ut-webpack pnpm add ut-webpack Imports
- utWebpack wrong
import utWebpack from 'ut-webpack'correctconst utWebpack = require('ut-webpack') - default (module.exports) wrong
export default function({utWebpack}) {...}correctmodule.exports = ({utWebpack}) => ({ options: {...}, use: [utWebpack({...})] }) - utWebpack function options wrong
utWebpack.publicPath('/my/path/')correctutWebpack({ publicPath: '/my/path/' })
Quickstart
// Install globally: npm install -g ut-webpack
// Create utWebpack.js in project root:
const path = require('path');
module.exports = ({utWebpack}) => ({
options: {
mains: {
admin: 'admin',
service: 'service'
},
publicPath: '/a/browser/',
source: 'browser',
output: path.resolve('dist'),
proxy: {
context: ['!/a/browser/**'],
target: 'http://localhost:8004'
}
},
use: [utWebpack({cssImport: path.resolve('impl/browser/config')})]
});
// Then use CLI: ut-webpack --mode production or ut-webpack-dev-server --mode development