Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My working Gists package.json & babelrc
{
"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"
]
}
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