Skip to content

Commit

Permalink
Modify Webpack configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
onurkerimov committed Dec 24, 2019
1 parent 98a7422 commit f9ac1ab
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 44 deletions.
44 changes: 0 additions & 44 deletions webpack.config.js

This file was deleted.

56 changes: 56 additions & 0 deletions webpack/webpack.config.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict'

const path = require('path')
const contentBase = path.resolve('./dist')

const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const settings = {
HtmlWebpackPlugin: {
template: './demo/src/index.html',
inject: true
}
}

module.exports = {
main: {
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin(settings.HtmlWebpackPlugin),
new ExtractTextPlugin('[name]')
],

entry: {
'js/main.js': path.resolve('./demo/src/index.js'),
// 'js/main.js': path.resolve('./src/index.js'),
//'css/main.css': path.resolve('./src/styles/index.scss')
},

output: {
filename: '[name]',
path: contentBase
},

module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /(\.sass|\.scss)$/,
use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
}
]
}
},

contentBase: contentBase
}
17 changes: 17 additions & 0 deletions webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const common = require('./webpack.config.common')

console.log('[Webpack] Use dev configuration\n')

module.exports = Object.assign(
{
mode: 'development',
devtool: '#source-map',
devServer: {
open: true, // to open the local server in browser
contentBase: common.contentBase //serve from 'dist' folder
}
},
common.main
)
14 changes: 14 additions & 0 deletions webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const common = require('./webpack.config.common')

console.log('[Webpack] Use prod configuration\n')

module.exports = Object.assign(
{
//mode: 'production',
mode: 'development',
devtool: '#source-map',
},
common.main
)

0 comments on commit f9ac1ab

Please sign in to comment.