Created
August 29, 2017 15:51
-
-
Save mariohmol/0b2bbe7e44e45db274824ab4909fb9e0 to your computer and use it in GitHub Desktop.
webpack css for ssr
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
"use strict"; | |
const path = require("path"); | |
const { join, resolve } = require('path'); | |
const loaders = require('./webpack/loaders'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const extractSass = new ExtractTextPlugin({ | |
filename: "[name].[contenthash].css" | |
// disable: process.env.NODE_ENV === "development" | |
}); | |
module.exports = { | |
entry: require.resolve('./app/app.scss'), | |
output: { | |
filename: 'style.css', | |
path: path.resolve(__dirname, 'dist') | |
}, | |
// watch: true, | |
module: { | |
rules: [ | |
{ // regular css files | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract({ | |
loader: 'css-loader?importLoaders=1', | |
}), | |
}, | |
{ // sass / scss loader for webpack | |
test: /\.(sass|scss)$/, | |
loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) | |
} | |
] | |
}, | |
plugins: [ | |
// new webpack.ContextReplacementPlugin( | |
// /angular(\\|\/)core(\\|\/)@angular/, | |
// path.resolve('./src'), | |
// {} | |
// ), | |
new ExtractTextPlugin({ // define where to save the file | |
filename: '[name].bundle.css', | |
allChunks: true, | |
}), | |
new HtmlWebpackPlugin({ | |
template: './app/index.html', | |
inject: 'body', | |
}), | |
new CopyWebpackPlugin([ | |
{ from: 'app/assets/', to: 'assets/' } | |
, { from: '../app/src/assets/', to: 'assets/' } | |
]) | |
], | |
}; | |
function root(__path) { | |
return path.join(__dirname, __path); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment