Issues (94)

config/webpack.prod.js (2 issues)

1 View Code Duplication
const path = require( 'path' );
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
2
const webpack = require( 'webpack' );
3
const HtmlWebpackPlugin = require( 'html-webpack-plugin' );
4
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
5
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
6
const MinifyPlugin = require( 'babel-minify-webpack-plugin' );
7
8
const srcDir = path.resolve( __dirname, '..', 'src' );
9
const distDir = path.resolve( __dirname, '..', 'dist' );
10
const nodeModulesDir = path.resolve( require.resolve( '@material/switch/mdc-switch.scss' ), '..', '..', '..' );
11
12
module.exports = {
13
	mode: 'production',
14
15
	context: srcDir,
16
17
	devtool: false,
18
19
	entry: {
20
		application: './index.js',
21
		bundle: './controls/index.js'
22
	},
23
24
	output: {
25
		filename: '[name].min.js',
26
		path: distDir,
27
		publicPath: '/',
28
		sourceMapFilename: '[name].map'
29
	},
30
31
	module: {
32
		rules: [
33
			{
34
				test: /\.ejs$/,
35
				loader: 'ejs-loader'
36
			},
37
			{
38
				test: /\.html$/,
39
				use: [
40
					{
41
						loader: 'html-loader',
42
						options: {
43
							minimize: true
44
						}
45
					}
46
				]
47
			},
48
			{
49
				test: /\.js$/,
50
				loader: 'babel-loader',
51
				include: [ srcDir ],
52
				options: {
53
					presets: [ '@babel/preset-env' ]
54
				}
55
			},
56
			{
57
				test: /\.svg$/,
58
				loader: 'svg-inline-loader'
59
			},
60
			{
61
				test: /\.js$/,
62
				enforce: 'pre',
63
				exclude: /node_modules/,
64
				loader: 'eslint-loader',
65
				options: {
66
					emitWarning: true
67
				}
68
			},
69
			{
70
				test: /\.(scss|css)$/,
71
				use: ExtractTextPlugin.extract( {
72
					fallback: 'style-loader',
73
					use: [
74
						{
75
							loader: 'css-loader',
76
							options: {
77
								minimize: true
78
							}
79
						},
80
						{
81
							loader: 'sass-loader',
82
							options: {
83
								includePaths: [ nodeModulesDir ]
84
							}
85
						},
86
						{
87
							loader: 'postcss-loader',
88
							options: {
89
								plugins: loader => [ require( 'autoprefixer' )() ]
0 ignored issues
show
The parameter loader is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
90
							}
91
						}
92
					]
93
				} )
94
			},
95
			{
96
				test: /\.(jpg|jpeg|png|gif|ico)$/,
97
				loader: 'url-loader',
98
				query: {
99
					limit: 10000, // Use data url for assets <= 10KB
100
					name: './[name].[hash].[ext]'
101
				}
102
			}
103
		]
104
	},
105
106
	plugins: [
107
		new CopyWebpackPlugin( [
108
			{
109
				from: './../static',
110
				to: ''
111
			},
112
			{
113
				from: require.resolve( 'Iris/dist/iris.min.js' ),
114
				to: './static'
115
			},
116
			{
117
				from: require.resolve( 'sass.js/dist/sass.worker.js' ),
118
				to: './static'
119
			},
120
			{
121
				from: path.resolve( require.resolve( 'Buttons/scss/buttons.scss' ), '..' ),
122
				to: './scss/color-palette-scss/buttons'
123
			},
124
			{
125
				from: srcDir + '/controls/color/scss/utilities/color-classes.sass',
126
				to: './scss/color-palette-scss/classes/color-classes.scss'
127
			}
128
		] ),
129
130
		new MinifyPlugin(),
131
132
		new webpack.NamedModulesPlugin(),
133
134
		new HtmlWebpackPlugin( {
135
			template: path.join( srcDir, 'index.ejs' ),
136
			path: distDir,
137
			filename: 'index.html',
138
			hash: true,
139
			minify: {
140
				removeComments: true,
141
				minifyJS: true,
142
				minifyCSS: true,
143
				collapseWhitespace: true
144
			}
145
		} ),
146
147
		new ExtractTextPlugin( '[name].min.css' )
148
	]
149
};
150