mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-25 11:10:24 +01:00
88 lines
2.9 KiB
JavaScript
88 lines
2.9 KiB
JavaScript
|
const path = require('path');
|
||
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||
|
|
||
|
module.exports = {
|
||
|
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
||
|
entry: './src/index.js',
|
||
|
output: {
|
||
|
path: path.resolve(__dirname, 'dist'),
|
||
|
filename: 'posthog.bundle.js'
|
||
|
},
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
test: /\.js$/,
|
||
|
exclude: /(node_modules)/,
|
||
|
use: {
|
||
|
loader: 'babel-loader'
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
// Apply rule for .sass, .scss or .css files
|
||
|
test: /\.(sa|sc|c)ss$/,
|
||
|
|
||
|
// Set loaders to transform files.
|
||
|
// Loaders are applying from right to left(!)
|
||
|
// The first loader will be applied after others
|
||
|
use: [
|
||
|
{
|
||
|
// After all CSS loaders we use plugin to do his work.
|
||
|
// It gets all transformed CSS and extracts it into separate
|
||
|
// single bundled file
|
||
|
loader: MiniCssExtractPlugin.loader
|
||
|
},
|
||
|
{
|
||
|
// This loader resolves url() and @imports inside CSS
|
||
|
loader: "css-loader",
|
||
|
},
|
||
|
{
|
||
|
// Then we apply postCSS fixes like autoprefixer and minifying
|
||
|
loader: "postcss-loader"
|
||
|
},
|
||
|
{
|
||
|
// First we transform SASS to standard CSS
|
||
|
loader: "sass-loader",
|
||
|
options: {
|
||
|
implementation: require("sass")
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
// Now we apply rule for images
|
||
|
test: /\.(png|jpe?g|gif|svg)$/,
|
||
|
use: [
|
||
|
{
|
||
|
// Using file-loader for these files
|
||
|
loader: "file-loader",
|
||
|
|
||
|
// In options we can set different things like format
|
||
|
// and directory to save
|
||
|
options: {
|
||
|
outputPath: 'images'
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
// Apply rule for fonts files
|
||
|
test: /\.(woff|woff2|ttf|otf|eot)$/,
|
||
|
use: [
|
||
|
{
|
||
|
// Using file-loader too
|
||
|
loader: "file-loader",
|
||
|
options: {
|
||
|
outputPath: 'fonts'
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
plugins: [
|
||
|
new MiniCssExtractPlugin({
|
||
|
filename: "bundle.css"
|
||
|
})
|
||
|
]
|
||
|
};
|