Last active
March 16, 2018 12:48
-
-
Save mauroreisvieira/568652305edeef26d542b177eeb3b001 to your computer and use it in GitHub Desktop.
Webpack configurations for SCSS and Typescript
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 webpack = require('webpack'); | |
const path = require('path'); | |
const extractTextPlugin = require('extract-text-webpack-plugin'); | |
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
module.exports = { | |
entry : { | |
[NAME_SAVED_FILE]: './src/scripts/[NAME_FILE].ts' | |
}, | |
output: { | |
path: path.resolve(__dirname, 'dist/'), | |
filename: '[name].min.js', | |
publicPath: '/dist' | |
}, | |
devtool: "source-map", | |
module: { | |
rules: [ | |
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" }, | |
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }, | |
{ | |
test: /\.scss$/, | |
use: extractTextPlugin.extract({ | |
use: [{ | |
loader: "css-loader" | |
}, { | |
loader: "sass-loader" | |
}], | |
fallback: "style-loader" | |
}) | |
} | |
], | |
loaders: [ | |
{ | |
test: /\.scss$/, | |
loader: extractTextPlugin.extract('css!sass'), | |
options: { | |
minimize: true | |
} | |
} | |
] | |
}, | |
resolve: { | |
extensions: [".ts", ".tsx", ".js", ".json", ".scss"], | |
modules: ['src', 'node_modules'] | |
}, | |
plugins: [ | |
new extractTextPlugin('../dist/[name].css', { | |
allChunks: true | |
}), | |
new webpack.DefinePlugin({ | |
'process.env.NODE_ENV': JSON.stringify('development') | |
}), | |
new UglifyJsPlugin() | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment