Skip to content

Instantly share code, notes, and snippets.

@kuju63
Last active August 6, 2018 15:27
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 kuju63/b388873d147e445bc225bc1aac4c3590 to your computer and use it in GitHub Desktop.
Save kuju63/b388873d147e445bc225bc1aac4c3590 to your computer and use it in GitHub Desktop.
webpack4 + TypeScript + SCSS構成のwebpack設定(CSSはJSに含めない)
const path = require('path');
mode = process.env.NODE_ENV,
devMode = mode !== 'production',
MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: mode,
entry: {
main: path.resolve(__dirname, './ts/login.ts')
},
output: {
path: path.join(__dirname, 'wwwroot'),
filename: 'js/[name].js'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
devtool: 'source-map',
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[id].css'
})
],
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader'
},
{
test: /\.(sc|sa|c)ss/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader',
options: {
url: false,
sourceMap: true,
minimize: true,
importLoaders: 2
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment