This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
74 lines (66 loc) 路 2.68 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const webpack = require('webpack');
const path = require('path');
const { merge } = require('webpack-merge');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const SizePlugin = require('size-plugin');
const buildPath = path.resolve(__dirname, 'dist');
const publicPath = `/src/Frontend/Themes/${path.basename(__dirname)}/dist/`;
module.exports = (env, argv) => {
const commonConfig = {
entry: {
app: path.resolve(__dirname, './Core/Js/app.ts'),
},
output: {
path: buildPath,
publicPath: publicPath,
},
// Webpack does not look for .ts files by default. Configure it to look for Typescript files too.
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: {
loader: 'url-loader',
options: {
name: 'fonts/[name].[ext]',
},
},
},
],
},
plugins: [
// Clean the dist folder before running webpack.
new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: ['**/*', '!manifest.json'] }),
// Show the progress while building.
new webpack.ProgressPlugin(),
// Print the gzipped sizes of your webpack assets and changes since the last build.
new SizePlugin(),
// Generate an asset manifest file, so we can leverage Symfony 3.3's Manifest-based asset versioning
// See https://symfony.com/blog/new-in-symfony-3-3-manifest-based-asset-versioning
new WebpackManifestPlugin({
publicPath,
writeToFileEmit: true, // Make sure manifest is created on webpack-dev-server too!
}),
].filter(Boolean),
};
// Merge our common configuration with the environment-specific (dev/prod) config.
const envConfig = require(`./webpack.${argv.mode}`);
return merge({ mode: argv.mode }, commonConfig, envConfig);
};