ClickHouse/docs/tools/webpack.config.js

82 lines
2.0 KiB
JavaScript
Raw Normal View History

2021-09-08 18:08:10 +00:00
const path = require('path');
2021-09-09 23:21:13 +00:00
const jsPath = path.resolve(__dirname, '../../website/src/js');
2021-09-08 19:36:00 +00:00
const scssPath = path.resolve(__dirname, '../../website/src/scss');
console.log(path.resolve(__dirname, 'node_modules/bootstrap', require('bootstrap/package.json').sass));
2021-09-08 18:08:10 +00:00
module.exports = {
mode: ('development' === process.env.NODE_ENV) && 'development' || 'production',
...(('development' === process.env.NODE_ENV) && {
watch: true,
}),
entry: [
2021-09-08 19:36:00 +00:00
path.resolve(scssPath, 'bootstrap.scss'),
path.resolve(scssPath, 'main.scss'),
2021-09-09 23:21:13 +00:00
path.resolve(jsPath, 'main.js'),
2021-09-08 18:08:10 +00:00
],
output: {
path: path.resolve(__dirname, '../../website'),
filename: 'js/main.js',
},
2021-09-08 19:36:00 +00:00
resolve: {
alias: {
bootstrap: path.resolve(__dirname, 'node_modules/bootstrap', require('bootstrap/package.json').sass),
},
},
2021-09-08 18:08:10 +00:00
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules)/,
use: [{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
}],
}, {
test: /\.scss$/,
use: [{
loader: 'file-loader',
options: {
sourceMap: true,
2021-09-08 19:36:00 +00:00
outputPath: (url, entryPath, context) => {
if (0 === entryPath.indexOf(scssPath)) {
const outputFile = entryPath.slice(entryPath.lastIndexOf('/') + 1, -5)
const outputPath = entryPath.slice(0, entryPath.lastIndexOf('/')).slice(scssPath.length + 1)
return `./css/${outputPath}/${outputFile}.css`
}
return `./css/${url}`
},
2021-09-08 18:08:10 +00:00
},
}, {
loader: 'postcss-loader',
options: {
options: {},
plugins: () => ([
require('autoprefixer'),
('production' === process.env.NODE_ENV) && require('cssnano'),
].filter(plugin => plugin)),
}
}, {
loader: 'sass-loader',
options: {
implementation: require('sass'),
implementation: require('sass'),
sourceMap: ('development' === process.env.NODE_ENV),
sassOptions: {
importer: require('node-sass-glob-importer')(),
precision: 10,
},
},
}],
}],
},
};