Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@nowa/module-webpack
Advanced tools
export interface IOptions {
mode?: 'run' | 'watch' | 'devServer';
}
export type ConfigFileContent =
| ((
{ context, options }: { context: string; options: object },
) => Webpack.Configuration | Webpack.Configuration[] | Promise<Webpack.Configuration | Webpack.Configuration[]>)
| Webpack.Configuration
| Webpack.Configuration[];
export type SingleConfig = /* path to configFile */ string | ConfigFileContent;
export type Config = ['webpack', SingleConfig | SingleConfig[], IOptions | undefined];
const config1 = ['webpack', 'sompath/webpack.config.js']; // config file
const config2 = ['webpack', ['sompath/webpack.app.js', 'sompath/webpack.page.js']]; // MultiCompiler
const config3 = ['webpack', { entry: './src/index.js', ...otherWebpackConfig }]; // raw config
const config4 = ['webpack', { watch: true, ...o }]; // watch mode
const config5 = ['webpack', { devServer: { ...d }, ...o }]; // devServer mode
const config6 = ['webpack', { devServer: { ...d }, ...o }, { mode: 'run' }]; // run mode (ignore devServer)
there are 3 modes now
if mode
is not set, module-webpack
will decide it directly from the final config.
config.devServer
is truthy => webpack-dev-serverconfig.watch
is truthy => webpack watch source files and changes triggers recompileWebpack supports exporting a function as a config. But its hard to use.
Therefore, module-webpack
replace that support with a more advanced solution.
Instead of function (env, argv) {}
from native webapck, module-webapck
supports function ({ context, options }) {}
context
is the project root (context
in nowa2
)options
is the nowa options
from your command line arguments, config and solutionnowa2 xxxx --language en --multiPage true
const config1 = [
'webpack',
{
config: ({ context, options }) => ({
context,
entry: `./src/index.${options.language}.js`, // ./src/index.en.js
...otherWebpackConfig,
}),
},
];
const config2 = ['webpack', 'sompath/webpack.config.js'];
with sompath/webpack.config.js
module.exports = async ({ context, options }) => {
if (option.multiPage /* true */) {
// ...
}
// ...
};
In some cases we need modify webpack
config, but we cannot change nowa soltion
directly (in a npm package).
We can create a webpack.config.js
in project root. In this file you can access then final webpack config and return a new one to replace it.
This file can export a fucntion, the function signature is function (originalConfig, rumtime, webpack) {}
nowa
, will be passed to webpack soon
- string
context
- object
options
- Array
commands
is the actual command you type
e.g.nowa2 build prod
=>['build', 'prod']
- object
config
is the module config formodule-webpack
in yousolution
it also supports specify which command the overwrite will take place like config
/ solution
module.exports = (config, rumtime, webpack) => {
// overwrite all command using module-webpack
config.plugins.push(new webpack.SomeBuiltinPlugin());
return config;
};
module.exports = {
// export an object instead of fucntion
build: [
(config, rumtime, webpack) => {
// overwrite on build command only
config.plugins.push(new webpack.SomeBuiltinPlugin());
return config;
},
],
dev: [
(config, rumtime, webpack) => {
// overwrite on dev command only
config.plugins.push(new webpack.SomeOtherBuiltinPlugin());
return config;
},
],
};
FAQs
the nowa webpack module
The npm package @nowa/module-webpack receives a total of 2 weekly downloads. As such, @nowa/module-webpack popularity was classified as not popular.
We found that @nowa/module-webpack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.