Last active
August 9, 2017 13:48
-
-
Save VitorLuizC/ac6a1f1188e8c470799f3e980b26ecf8 to your computer and use it in GitHub Desktop.
Webpack hangs on building modules
This file contains hidden or 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": "landing-page-unopar", | |
| "version": "0.0.1", | |
| "description": "Landing Page de Unopar.", | |
| "private": true, | |
| "author": "Vitor Cavalcanti", | |
| "maintainers": [], | |
| "license": "MIT", | |
| "keywords": [ | |
| "landing-page", | |
| "lp", | |
| "front-end" | |
| ], | |
| "main": "./src/script/index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "dev": "webpack-dev-server --hot --content-base ./dist --progress", | |
| "build": "webpack -p --env production --hide-modules --progress" | |
| }, | |
| "dependencies": { | |
| "babel-polyfill": "^6.23.0", | |
| "picturefill": "^3.0.2", | |
| "rupture": "^0.6.2" | |
| }, | |
| "devDependencies": { | |
| "autoprefixer": "^7.0.1", | |
| "babel-core": "^6.24.1", | |
| "babel-loader": "^7.0.0", | |
| "babel-plugin-transform-object-rest-spread": "^6.23.0", | |
| "babel-preset-es2015": "^6.24.1", | |
| "css-loader": "^0.28.1", | |
| "cssnano": "^3.10.0", | |
| "extract-text-webpack-plugin": "^2.1.0", | |
| "file-loader": "^0.11.1", | |
| "html-minifier": "^3.4.4", | |
| "html-webpack-plugin": "^2.28.0", | |
| "image-webpack-loader": "^3.3.1", | |
| "postcss-loader": "^2.0.5", | |
| "pug": "^2.0.0-rc.1", | |
| "pug-loader": "^2.3.0", | |
| "style-loader": "^0.17.0", | |
| "stylus": "^0.54.5", | |
| "stylus-loader": "^3.0.1", | |
| "webpack": "^2.5.1", | |
| "webpack-dev-server": "^2.4.5" | |
| } | |
| } |
This file contains hidden or 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 { UglifyJsPlugin } = require('webpack').optimize | |
| const HtmlPlugin = require('html-webpack-plugin') | |
| const ExtractTextPlugin = require('extract-text-webpack-plugin') | |
| const babel = { | |
| test: /\.js$/, | |
| use: 'babel-loader' | |
| } | |
| const pug = { | |
| test: /\.pug$/, | |
| use: { | |
| loader: 'pug-loader', | |
| options: { | |
| pretty: true | |
| } | |
| } | |
| } | |
| const stylus = { | |
| test: /\.styl$/, | |
| use: ExtractTextPlugin.extract({ | |
| fallback: 'style-loader', | |
| use: [ | |
| { | |
| loader: 'css-loader', | |
| options: { | |
| sourceMap: true, | |
| minimize: false | |
| } | |
| }, | |
| { | |
| loader: 'postcss-loader', | |
| options: { | |
| sourceMap: true | |
| } | |
| }, | |
| { | |
| loader: 'stylus-loader', | |
| options: { | |
| sourceMap: true, | |
| paths: ['node_modules'], | |
| 'resolve url': true, | |
| 'include css': true | |
| } | |
| } | |
| ] | |
| }) | |
| } | |
| const favicon = { | |
| test: /(apple-touch-icon|favicon)\.(ico|png)$/, | |
| use: { | |
| loader: 'file-loader', | |
| options: { | |
| name: '[name].[ext]' | |
| } | |
| } | |
| } | |
| const image = { | |
| test: /\.(png|jpe?g)$/, | |
| exclude: favicon.test, | |
| use: [ | |
| { | |
| loader: 'file-loader', | |
| options: { | |
| name: 'img/[name].[ext]' | |
| } | |
| }, | |
| // | |
| // { | |
| // loader: 'image-webpack-loader', | |
| // options: {} | |
| // } | |
| ] | |
| } | |
| const font = { | |
| test: /\.(eot|ttf|woff2?|svg)$/, | |
| use: { | |
| loader: 'file-loader', | |
| options: { | |
| name: 'font/[name].[ext]' | |
| } | |
| } | |
| } | |
| const config = { | |
| entry: { | |
| main: './src/script/index.js', | |
| vendors: ['babel-polyfill', 'picturefill'] | |
| }, | |
| output: { | |
| filename: '[name].js', | |
| path: path.join(__dirname, './dist') | |
| }, | |
| module: { | |
| rules: [babel, pug, stylus, favicon, image, font] | |
| }, | |
| plugins: [ | |
| new HtmlPlugin({ | |
| filename: 'index.html', | |
| template: 'src/view/index.pug' | |
| }), | |
| new ExtractTextPlugin('style.css') | |
| ], | |
| devtool: false, | |
| target: 'web' | |
| } | |
| function getProduction() { | |
| pug.use.options.pretty = false // No modo de distribuição o Pug compilado e o | |
| config.plugins = [ // HTML resultante do webpack-html-plugin são | |
| new HtmlPlugin({ // minificados. | |
| minify: { | |
| removeStyleLinkTypeAttributes: true, | |
| removeScriptTypeAttributes: true, | |
| removeRedundantAttributes: true, | |
| removeAttributeQuotes: true, | |
| removeComments: true | |
| }, | |
| filename: 'index.html', | |
| template: 'src/view/index.pug' | |
| }), | |
| new ExtractTextPlugin('style.css'), | |
| new UglifyJsPlugin() | |
| ] | |
| return config | |
| } | |
| module.exports = env => (env === 'production') ? getProduction() : config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment