Skip to content

Instantly share code, notes, and snippets.

@mihalt
Last active April 24, 2019 15:21
Show Gist options
  • Save mihalt/ffdaaf3b1cdded5291102ff028e3d708 to your computer and use it in GitHub Desktop.
Save mihalt/ffdaaf3b1cdded5291102ff028e3d708 to your computer and use it in GitHub Desktop.
How to import one from styl files to all others
const webpack = require('webpack');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const BundleTracker = require('webpack-bundle-tracker');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: {
home: './frontend_src/js/home.js',
login: './frontend_src/js/login.js',
main: './frontend_src/js/main.js',
news: './frontend_src/js/news.js',
payment: './frontend_src/js/payment.js',
registration: './frontend_src/js/registration.js',
update_profile: './frontend_src/js/update_profile.js',
},
output: {
path: path.resolve(__dirname, '/static/js/'),
filename: '[name]-[hash].js',
},
module: {
rules: [
{
test: /\.(css|styl)$/,
use: [
'style-loader',
'css-loader',
'stylus-loader',
]
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images/'
}
},
]
},
{
test: /\.(woff|otf|eot|ttf)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'fonts/'
}
},
]
}
],
},
devtool: 'inline-source-map',
plugins: [
new CleanWebpackPlugin(),
new BundleTracker({filename: './webpack-stats.json'}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new MiniCssExtractPlugin({
filename: './static/csss/[name].css',
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment