Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// webpack.conf
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const path = require('path');
- module.exports = (env, argv) => ({
- entry: path.resolve(__dirname, 'src/scripts/index.js'),
- devServer: {
- contentBase: path.join(__dirname, '.'),
- compress: true,
- port: 8080
- },
- devtool: argv.mode === 'production' ? false : 'source-map',
- mode: argv.mode || 'development',
- output: {
- filename: 'bundle.js',
- path: path.resolve(__dirname, 'dist')
- },
- plugins: [new HtmlWebpackPlugin()],
- module: {
- rules: [
- {
- test: /\.js$/,
- exclude: /node_modules/,
- use: {
- loader: 'babel-loader',
- options: {
- presets: ['@babel/preset-env'],
- cacheDirectory: true
- },
- }
- },
- {
- test: /\.s?css$/,
- use: [
- 'style-loader',
- {
- loader: 'css-loader',
- options: {
- sourceMap: argv.mode !== 'production'
- }
- },
- {
- loader: 'postcss-loader',
- options: {
- ident: 'postcss',
- plugins: [
- require('autoprefixer'),
- ]
- }
- },
- 'sass-loader'
- ]
- },
- {
- test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/i,
- use: [
- 'url-loader?limit=10000',
- {
- loader: 'img-loader',
- options: {
- plugins: [
- require('imagemin-gifsicle')({
- interlaced: false
- }),
- require('imagemin-mozjpeg')({
- progressive: true,
- arithmetic: false
- }),
- require('imagemin-pngquant')({
- floyd: 0.5,
- speed: 2
- }),
- require('imagemin-svgo')({
- plugins: [
- { removeTitle: true },
- { convertPathData: false }
- ]
- })
- ]
- }
- }
- ]
- },
- ]
- }
- })
- /// package.json
- "scripts": {
- "start:dev": "webpack-dev-server",
- "build": "webpack --mode production"
- },
- "browserslist": [
- "defaults",
- "not ie < 11",
- "last 2 versions",
- "> 1%",
- "iOS 7",
- "last 3 iOS versions"
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement