Last active
June 1, 2017 13:29
-
-
Save gustavoquinalha/520967e851826b7ab58f61763272e243 to your computer and use it in GitHub Desktop.
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": "webpack-aula", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"dev": "webpack", | |
"production": "NODE_ENV=production webpack", | |
"watch": "npm run dev -- --watch" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"babel-core": "^6.24.1", | |
"babel-loader": "^7.0.0", | |
"babel-preset-es2015": "^6.24.1", | |
"css-loader": "^0.28.4", | |
"extract-text-webpack-plugin": "^2.1.0", | |
"file-loader": "^0.11.1", | |
"node-sass": "^4.5.3", | |
"purify-css": "^1.2.2", | |
"purifycss-webpack": "^0.7.0", | |
"raw-loader": "^0.5.1", | |
"sass-loader": "^6.0.5", | |
"style-loader": "^0.18.1", | |
"webpack": "^2.6.1" | |
} | |
} |
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
var webpack = require('webpack'); | |
var path = require('path'); | |
var glob = require('glob'); | |
var ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
let PurifyCSSPlugin = require('purifycss-webpack'); | |
var inProduction = (process.env.NODE_ENV === 'production'); | |
module.exports = { | |
entry: { | |
app: [ | |
'./src/main.js', | |
'./src/main.scss' | |
] | |
}, | |
output: { | |
path: path.resolve(__dirname, './dist'), | |
filename: '[name].js' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.s[ac]ss$/, | |
use: ExtractTextPlugin.extract({ | |
use: ['css-loader', 'sass-loader'], | |
fallback: 'style-loader' | |
}) | |
}, | |
{ | |
test: /\.png|jpe?g|svg$/, | |
loader: 'file-loader', | |
options: { | |
name: 'images/[name][hash].[ext]' | |
} | |
}, | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: "babel-loader" | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin('[name].css'), | |
new PurifyCSSPlugin({ | |
paths: glob.sync(path.join(__dirname, '**/*.html')), | |
minimize: inProduction | |
}), | |
new webpack.LoaderOptionsPlugin({ | |
minimize: inProduction | |
}) | |
] | |
}; | |
if (inProduction) { | |
module.exports.plugins.push( | |
new webpack.optimize.UglifyJsPlugin() | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment