Last active
November 3, 2017 10:51
-
-
Save vegarnorman/ca548bb2d4875b99739ee247da881e62 to your computer and use it in GitHub Desktop.
Webpack with Sass, PostCSS and JavaScript/JSX
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
Show hidden characters
{ | |
"presets": ["env", "react"] | |
} |
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
{ | |
"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" | |
} | |
} |
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
module.exports = { | |
plugins: [ | |
require('autoprefixer'), | |
require('cssnano') | |
] | |
}; |
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'); | |
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