@tarantool.io/webpack-config
v2.1.0
Published
Sharable webpack configuration for Tarantool projects.
Downloads
4,597
Keywords
Readme
@tarantool.io/webpack-config
Sharable webpack configuration for Tarantool projects.
Usage
// webpack.config.js
const namespace = 'cluster';
const root = __dirname;
module.exports = require("@tarantool.io/webpack-config")({
namespace,
root,
});
Full example
// webpack.config.js
const path = require('path');
const namespace = 'cluster';
const root = __dirname;
const src = path.join(root, 'src');
const build = path.join(root, 'build');
const entry = path.join(src, 'index.ts');
const htmlTemplate = path.join(root, 'public', 'index.html');
module.exports = require("@tarantool.io/webpack-config")({
// [default: depends on env.NODE_ENV] 'prod' or 'dev' build type configuration
type: 'prod',
// [default: ''] static files namespace path used in webpack 'output.*filename' and the @tarantool.io/lua-bundler-webpack-plugin plugin
namespace,
// [default: process.cwd()] path to the root (project) folder
root,
// [default: root + '/src'] path to the src folder
entry,
// [default: root + '/build'] path to the build folder
build,
// [default: ''] path to the html template used in the HtmlWebpackPlugin
htmlTemplate,
// [default: depends on env.PUBLIC_PATH or '/'] Webpack 'output.publicPath' configuration
publicPath: '/',
// [default: depends on env.WEBPACK_USE_LUA] enables the @tarantool.io/lua-bundler-webpack-plugin plugin
lua: true,
// [default: depends on env.WEBPACK_USE_EMOTION] enables the @emotion/babel-plugin plugin
emotion: true,
// [default: depends on env.WEBPACK_USE_SASS] enables the sass-loader
sass: true,
// [default: depends on env.WEBPACK_USE_LINT] enables the eslint-webpack-plugin plugin
lint: true,
// [default: depends on env.WEBPACK_SOURCE_MAP] enables sourceMap in result build
sourceMap: false,
// [default: depends on env.WEBPACK_USE_BUNDLE_ANALYZER_PLUGIN] enables the webpack-bundle-analyzer plugin
analyze: false,
// [default: depends on env.WEBPACK_MANIFEST_FILE_NAME] configuration in the webpack-manifest-plugin webpack plugin
webpackManifestFileName: 'asset-manifest.json',
// [default: depends on env.WEBPACK_BABEL_PRESENT_ENV_DEBUG] enables the debug configuration in the @babel/preset-env preset
debugBabelPresetEnv: false,
// [default: undefined] webpack 'resolve.alias' configuration
alias: {
'~': src
},
// [default: undefined] environment variables used in the DefinePlugin plugin
env: {
REACT_SOME_VAR: 'true',
},
// [default: undefined] configuration used in the copy-webpack-plugin plugin
copy: [],
// [default: undefined] webpack 'externals' configuration
externals: {
react: 'react',
'react-dom': 'reactDom',
},
// [default: depends on env.HOST or '127.0.0.1'] host configuration used in the webpack dev server configuration
host: '127.0.0.0'
// [default: depends on env.PORT or 3000] port configuration used in the webpack dev server configuration
port: 3000,
// [default: undefined] proxy configuration used in the webpack dev server configuration
proxy: {
'/api': 'http://localhost:8081',
};
// [default: undefined] function to change the configuration before creation
middleware: (cfg) => {
cfg.cache = false;
return cfg;
}
});