Last active
January 27, 2024 17:27
-
-
Save pawarvijay/dcf5fb1ec33350f32ebcf9f0cfb35286 to your computer and use it in GitHub Desktop.
My working Gists package.json & babelrc
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": [ | |
"react", | |
[ | |
"env", | |
{ | |
"targets": { | |
"browsers": ["last 1 versions"] | |
}, | |
"debug": true, | |
"modules": "commonjs" | |
} | |
] | |
], | |
"plugins": [ | |
"transform-object-rest-spread", | |
"transform-class-properties", | |
"syntax-dynamic-import", | |
"transform-runtime" | |
] | |
} |
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 ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const autoprefixer = require('autoprefixer'); | |
const webpack = require('webpack'); | |
const extractSass = new ExtractTextPlugin({ | |
filename: "[name].css", | |
allChunks: false, | |
disable: true | |
}); | |
module.exports = { | |
target: 'web', | |
devtool: 'inline-source-map', | |
entry: { | |
'index': './src/index.js' | |
}, | |
resolve: { | |
alias: { | |
commonfonts: path.resolve(__dirname, 'src/components/common/assets/fonts') | |
} | |
}, | |
output: { | |
filename: '[name].bundle.js', | |
chunkFilename: '[name].bundle.js', | |
path: __dirname + '/build', | |
publicPath: '/', | |
sourceMapFilename: '[name].map', | |
pathinfo: true, | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
loader: [ | |
'babel-loader' | |
], | |
exclude: [/node_modules/] | |
}, | |
{ | |
test: /\.(scss|css)$/, | |
use: extractSass.extract({ | |
use: [ | |
{ | |
loader: "css-loader", | |
options: { | |
sourceMap: true | |
} | |
}, | |
{ | |
loader: "sass-loader", | |
options: { | |
sourceMap: true | |
} | |
}, | |
{ | |
loader: require.resolve('postcss-loader'), | |
options: { | |
ident: 'postcss', | |
plugins: () => [ | |
autoprefixer({ | |
browsers: [ | |
'>1%', | |
'last 2 versions', | |
'Firefox ESR', | |
'not ie < 9', | |
], | |
flexbox: 'no-2009', | |
}), | |
], | |
}, | |
}, | |
], | |
fallback: "style-loader" | |
}) | |
}, | |
{ | |
test: /\.(png|svg|jpe?g|gif)$/, | |
use: [ | |
{ | |
loader: 'file-loader', | |
options: { | |
name: '[name].[ext]', | |
outputPath: 'images/' | |
} | |
} | |
] | |
}, | |
{ | |
test: /\.(woff|woff2|eot|ttf|otf)$/, | |
use: [ | |
{ | |
loader: 'file-loader', | |
options: { | |
name: '[name].[ext]', | |
outputPath: 'fonts/' | |
} | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new CleanWebpackPlugin(['build']), | |
extractSass, | |
new HtmlWebpackPlugin({ title: 'Instarem.com', 'template': __dirname + '/src/index.tmpl.html' }), | |
new webpack.optimize.CommonsChunkPlugin({ name: 'commonChunk' }), | |
new CopyWebpackPlugin( | |
[ | |
{ | |
from: 'src/**/*.+(png|jpg)', | |
to: 'images/[name].[ext]' | |
} | |
] | |
) | |
], | |
devServer: { | |
contentBase: './build', | |
port: 9000, | |
historyApiFallback: true, | |
host: 'localhost' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment