This is the webpack.config.js file that I used when I tried to compile css into a separate file
|-- App |-- dist |-- src |-- css |-- header.css |-- sass |-- img |-- partials |-- _variables.scss |-- main.scss |--ts |-- tsconfig.json |-- user.ts |-- main.js |-- app.js |-- webpack.config.js var ExtractTextPlugin = require("extract-text-webpack-plugin"); var extractCss = new ExtractTextPlugin("css/style.css"); var autoprefixer = (require("autoprefixer"))({ browsers: ['last 2 versions'] }); var precss = require("precss"); var sugarss = require('sugarss'); var colormin = require('postcss-colormin'); var path = require("path"); module.exports = { entry: { app: ['./src/sass/main.scss', './src/main.js'] }, //devtool:"source-map", output:{ filename: "bundle.js", path: path.resolve(__dirname,"dist"), publicPath: "/dist/" }, resolve: { extensions: ['', '.webpack.js', '.web.js', '.ts', '.js'] }, module:{ loaders:[ { test:/\.s?(a|c)ss$/, exclude: /node_modules/, loader: ExtractTextPlugin.extract("css!postcss!sass") },/* { test:/\.css$/, exclude: /node_modules/, loader: ExtractTextPlugin.extract("style-loader", "css-loader", "postcss-loader","precss") },*/ { test: /\.(jpe?g|png|gif|svg)$/i, loaders: [ 'file?hash=sha512&digest=hex&name=[hash].[ext]', 'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false' ] }, { test: /\.ts$/, loader: 'ts-loader' } ] }, plugins: [ new ExtractTextPlugin("bundle.css") ], postcss: function(){ return { plugins: [ autoprefixer, precss ] } } }
source share