Skip to content

Instantly share code, notes, and snippets.

@RahulDey12
Last active September 2, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RahulDey12/ee6359dc038a9c4de9b083b7ce3f44d3 to your computer and use it in GitHub Desktop.
Save RahulDey12/ee6359dc038a9c4de9b083b7ce3f44d3 to your computer and use it in GitHub Desktop.
SASS, JS Starter
{
"private": true,
"scripts": {
"dev": "webpack --progress --mode=development",
"watch": "npm run dev -- --watch",
"dist": "webpack -p --mode=production"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"autoprefixer": "^9.7.6",
"babel-loader": "^8.1.0",
"css-loader": "^3.5.1",
"file-loader": "^4.2.0",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.3.1",
"terser-webpack-plugin": "^1.4.2",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"browserslist": [
"defaults",
"not ie < 11",
"last 2 versions",
"> 1%",
"iOS 7",
"last 3 iOS versions"
]
}
module.exports = {
plugins: [
require('autoprefixer')
]
};
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const webpack = require('webpack');
module.exports = {
entry: './src/js/app.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: './js/app.js',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['@babel/preset-env']
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development',
}
},
'css-loader',
{
loader: 'postcss-loader',
options: {
config: {
path: 'postcss.config.js'
}
}
},
'sass-loader',
],
},
{
test: /\.(jpg|png|webp|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [
{
loader: 'file-loader',
options: {
publicPath: '../public/',
outputPath: 'public'
}
}
]
}
]
},
optimization: {
minimizer: [new TerserPlugin({}), new OptimizeCSSAssetsPlugin({})],
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: './css/[name].css',
}),
],
stats: {
colors: true
},
devtool: 'source-map'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment