Created
January 24, 2019 16:56
-
-
Save corocoto/b778f1914fe59db0a5aa6ec11b9fc809 to your computer and use it in GitHub Desktop.
Webpack Starter Template
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
Show hidden characters
| { | |
| "presets": [ | |
| "env", | |
| "stage-3" | |
| ] | |
| } |
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": "test", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "build": "webpack --mode production", | |
| "dev": "webpack-dev-server --mode development --open" | |
| }, | |
| "author": "CreativeRusBear", | |
| "license": "ISC", | |
| "devDependencies": { | |
| "babel-core": "^6.26.3", | |
| "babel-loader": "^7.1.5", | |
| "babel-preset-env": "^1.7.0", | |
| "babel-preset-stage-3": "^6.24.1", | |
| "css-loader": "^0.28.11", | |
| "extract-text-webpack-plugin": "^4.0.0-beta.0", | |
| "path": "^0.12.7", | |
| "webpack": "^4.29.0", | |
| "webpack-cli": "^3.2.1", | |
| "webpack-dev-server": "^3.1.14" | |
| } | |
| } |
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
| let path = require('path'), | |
| ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
| let conf = { | |
| entry: './src/js/script.js', | |
| output: { | |
| path: path.resolve(__dirname, './dist/js'), | |
| filename: 'app.js', | |
| publicPath: '/dist/js' | |
| }, | |
| devServer: { | |
| overlay: true | |
| }, | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.js$/, | |
| loader: 'babel-loader' | |
| }, | |
| { | |
| test: /\.css$/, | |
| use: ExtractTextPlugin.extract({ | |
| use: 'css-loader' | |
| }) | |
| } | |
| ] | |
| }, | |
| plugins: [ | |
| new ExtractTextPlugin('../css/style.css'), | |
| ] | |
| }; | |
| module.exports = (env, options)=>{ | |
| let prod = options.mode==='production'; | |
| conf.devtool = prod ? 'source-map' : 'eval-sourcemap'; | |
| return conf; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment