Answer the question
In order to leave comments, you need to log in
How to make a certain page on localhost by default?
webpack config
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const pug = require('./webpack/pug');
const devserver = require('./webpack/devserver');
const sass = require('./webpack/sass');
const extractCSS = require('./webpack/css.extract');
const css = require('./webpack/css');
const webpack = require('webpack');
const sourceMap = require('./webpack/sourceMap');
const lintJS = require('./webpack/js.lint');
const lintCSS = require('./webpack/sass.lint');
const images = require('./webpack/images');
const babel = require('./webpack/babel');
const favicon = require('./webpack/favicon');
const PATHS = {
source: path.join(__dirname, 'source'),
build: path.join(__dirname, 'build'),
};
const common = merge([
{
entry: {
'basket': PATHS.source + '/pages/basket/basket.js',
'index': PATHS.source + '/pages/index/index.js'
},
output: {
path: PATHS.build,
filename: './js/[name].js',
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new HtmlWebpackPlugin({
filename: 'basket.html',
chunks: ['basket', 'common'],
template: PATHS.source + '/pages/basket/basket.pug',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
chunks: ['index', 'common'],
template: PATHS.source + '/pages/index/index.pug',
}),
],
optimization: {
splitChunks: {
cacheGroups: {
'common': {
minChunks: 2,
chunks: 'all',
name: 'common',
priority: 10,
enforce: true,
},
},
},
},
},
pug(),
// lintJS({ paths: PATHS.sources }),
lintCSS(),
images(),
babel(),
]);
module.exports = function(env, argv) {
if (argv.mode === 'production') {
return merge([
common,
extractCSS(),
favicon(),
]);
}
if (argv.mode === 'development') {
return merge([
common,
devserver(),
sass(),
css(),
sourceMap(),
]);
}
};
Answer the question
In order to leave comments, you need to log in
Start reading the documentation, for example.
https://webpack.js.org/configuration/dev-server/#d...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question