Skip to content

Instantly share code, notes, and snippets.

@vegarnorman
Last active November 3, 2017 10:51
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 vegarnorman/ca548bb2d4875b99739ee247da881e62 to your computer and use it in GitHub Desktop.
Save vegarnorman/ca548bb2d4875b99739ee247da881e62 to your computer and use it in GitHub Desktop.
Webpack with Sass, PostCSS and JavaScript/JSX
{
"presets": ["env", "react"]
}
{
"name": "sample",
"version": "1.0.0",
"description": "Sample",
"main": "index.js",
"scripts": {
"test": "jest",
"dev": "webpack-dev-server",
"build": "webpack"
},
"devDependencies": {
"autoprefixer": "^7.1.6",
"babel": "^6.23.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"cssnano": "^3.10.0",
"extract-text-webpack-plugin": "^3.0.2",
"jest": "^21.2.1",
"node-sass": "^4.5.3",
"postcss": "^6.0.14",
"postcss-loader": "^2.0.8",
"sass-loader": "^6.0.6",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4"
}
}
module.exports = {
plugins: [
require('autoprefixer'),
require('cssnano')
]
};
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: {
app: ['./src/js/index.js', './src/css/master.scss']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ }
],
rules: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [{loader: 'css-loader', options: {importLoaders: 1}}, {loader: 'postcss-loader'}, {loader: 'sass-loader'}]
})
}
]
},
plugins: [
new ExtractTextPlugin('style.css', {allChunks: true}),
new UglifyJSPlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment