Last active
August 6, 2018 15:27
-
-
Save kuju63/b388873d147e445bc225bc1aac4c3590 to your computer and use it in GitHub Desktop.
webpack4 + TypeScript + SCSS構成のwebpack設定(CSSはJSに含めない)
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'); | |
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