Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
webpack: (config) => {
// for Debug (JSON.stringifyでは一部の型のtoStringがnullになってしまうため、console.log(confg)も併用した方がよい)
// console.log(JSON.stringify(config))
// for TypeScript build
config.resolve.extensions = [
...config.resolve.extensions,
...[".ts", ".tsx"],
]
config.entry = GlobEntriesPlugin.getEntries([
resolve("app", "*.{js,mjs,jsx,ts,tsx}"),
resolve("app", "?(scripts)/*.{js,mjs,jsx,ts,tsx}"),
])
config.module.rules.push({
test: /\.tsx?$/,
use: [
{
loader: "babel-loader",
options: babelOptions,
},
],
})
config.module.rules.push({
test: /\.css/,
// Source-Maps
config.devtool = devtool
/******************************/
/* WEBPACK.ENTRY */
/******************************/
const entries = []
// Add main entry glob
entries.push(resolve(src, '*.{js,mjs,jsx}'))
entries.push(resolve(src, '?(scripts)/*.{js,mjs,jsx}'))
// We use the GlobEntriesPlugin in order to
// restart the compiler in watch mode, when new
// files got added.
config.entry = GlobEntriesPlugin.getEntries(
entries
)
/******************************/
/* WEBPACK.OUTPUT */
/******************************/
config.output = {
path: target,
filename: '[name].js',
chunkFilename: '[id].chunk.js'
}
/******************************/
/* WEBPACK.OPTIMIZATION */
/******************************/
config.optimization = { minimize: minimize }
module.exports = env => {
return {
// Set the mode based on whether we're in production or dev.
mode : env.production ? 'production' : 'development',
// Only generate source maps if we're in a dev environment.
devtool : env.production ? undefined : 'source-maps',
entry : WebpackWatchedGlobEntries.getEntries( config.entry ),
output : {
path : config.paths.dist,
filename : config.output.scripts.filename
},
// Console stats output.
// @link https://webpack.js.org/configuration/stats/#stats
stats : 'minimal',
// External objects.
externals : config.externals,
// Resolve settings.
resolve : config.resolve,