Last active
December 9, 2018 23:49
-
-
Save Zerg00s/a96286dee5e4e8f1be7b7fb3e7ed9f3d to your computer and use it in GitHub Desktop.
Webpack scss transpiling. minimum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const MiniCss = require('mini-css-extract-plugin'); | |
module.exports = (env = {}, argv = {}) => { | |
const config = { | |
mode: argv.mode || 'development', // we default to development when no 'mode' arg is passed | |
// mode: argv.mode || 'production', // we default to development when no 'mode' arg is passed | |
entry: { | |
main: path.join(__dirname, 'styles', 'index.scss'), | |
}, | |
output: { | |
path: path.resolve(__dirname, '../wwwroot/dist'), | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.scss$/, | |
use: [ | |
// TODO: add css minifications | |
// TODO: add source maps for the .sccs files | |
MiniCss.loader, // 3 | |
'css-loader', // 2 | |
'sass-loader' // 1 | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new MiniCss({}) | |
] | |
} | |
return config; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const MiniCss = require('mini-css-extract-plugin'); | |
module.exports = (env = {}, argv = {}) => { | |
const config = { | |
// cache: true, | |
mode: argv.mode || 'development', // we default to development when no 'mode' arg is passed | |
// mode: argv.mode || 'production', // we default to production when no 'mode' arg is passed | |
entry: { | |
'style.css': path.join(__dirname, 'styles', 'style.scss'), | |
'index.js': path.join(__dirname, 'scripts', 'index.ts'), | |
}, | |
output: { | |
path: path.resolve(__dirname, '../wwwroot/dist'), | |
filename: 'result-[name]' | |
}, | |
devtool: 'source-map', | |
module: { | |
rules: [ | |
{ | |
test: /\.scss$/, | |
use: [ | |
// TODO: add css minifications | |
// TODO: add source maps for the .sccs files | |
MiniCss.loader, // 3 | |
'css-loader', // 2 | |
'sass-loader' // 1 | |
] | |
}, | |
{ | |
test: /\.ts(x?)$/, | |
exclude: /(node_modules|bower_components)/, | |
use: [ 'awesome-typescript-loader' ] | |
} | |
] | |
}, | |
plugins: [ | |
new MiniCss({}) | |
], | |
resolve: { | |
extensions: ['.ts', '.tsx', '.js'] | |
} | |
} | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment