webpack#BannerPlugin TypeScript Examples
The following examples show how to use
webpack#BannerPlugin.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: webpack.prod.ts From react-typescript-boilerplate with MIT License | 6 votes |
mergedConfig = merge(commonConfig, {
mode: 'production',
plugins: [
new BannerPlugin({
raw: true,
banner: COPYRIGHT,
}),
new HashedModuleIdsPlugin(),
new ForkTsCheckerWebpackPlugin({
typescript: {
// 生产环境打包并不频繁,可以适当调高允许使用的内存,加快类型检查速度
memoryLimit: 1024 * 2,
configFile: resolve(PROJECT_ROOT, './src/tsconfig.json'),
},
}),
new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash].css',
chunkFilename: 'css/[id].[contenthash].css',
ignoreOrder: false,
}),
new CompressionPlugin({ cache: true }),
],
optimization: {
runtimeChunk: 'single',
minimize: true,
minimizer: [new TerserPlugin({ extractComments: false }), new OptimizeCSSAssetsPlugin()],
},
})
Example #2
Source File: webpack.config.ts From swarm-cli with BSD 3-Clause "New" or "Revised" License | 4 votes |
base = (env?: Partial<WebpackEnvParams>): Configuration => {
const isProduction = env?.mode === 'production'
const filename = env?.fileName || ['index.js'].filter(Boolean).join('')
const entry = Path.resolve(__dirname, 'src')
const path = Path.resolve(__dirname, 'dist')
const target = 'node'
const plugins: WebpackPluginInstance[] = [
new DefinePlugin({
'process.env.ENV': env?.mode || 'development',
'process.env.IS_WEBPACK_BUILD': 'true',
}),
new BannerPlugin({ banner: '#!/usr/bin/env node', raw: true }),
]
return {
bail: Boolean(isProduction),
mode: env?.mode || 'development',
devtool: isProduction ? false : 'cheap-module-source-map',
entry,
output: {
path,
filename,
sourceMapFilename: filename + '.map',
library: PackageJson.name,
libraryTarget: 'umd',
globalObject: 'this',
},
module: {
rules: [
{
test: /\.(ts|js)$/,
// include: entry,
use: {
loader: 'babel-loader',
},
},
],
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
path: false,
fs: false,
},
},
optimization: {
minimize: isProduction,
minimizer: [
// This is only used in production mode
new TerserPlugin({
terserOptions: {
parse: {
// we want terser to parse ecma 8 code. However, we don't want it
// to apply any minfication steps that turns valid ecma 5 code
// into invalid ecma 5 code. This is why the 'compress' and 'output'
// sections only apply transformations that are ecma 5 safe
// https://github.com/facebook/create-react-app/pull/4234
ecma: 2018,
},
compress: {
ecma: 5,
},
mangle: {
safari10: true,
},
output: {
ecma: 5,
comments: false,
},
},
// Use multi-process parallel running to improve the build speed
// Default number of concurrent runs: os.cpus().length - 1
parallel: true,
}),
],
},
plugins,
target,
node: {
global: true,
__filename: 'mock',
__dirname: 'mock',
},
performance: {
hints: false,
},
watch: !isProduction,
}
}