Last active
October 22, 2017 12:15
-
-
Save JeansBolong/c6ba24f161379a5d6143a4e1ec1b7e40 to your computer and use it in GitHub Desktop.
Webpack Config
This file contains 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
// var webpack = require("webpack"); | |
const path = require('path'); | |
module.exports ={ | |
entry: "./src/client.js", | |
output:{ | |
path: path.resolve(__dirname, 'dist/assets/js'), | |
filename: "bundle.js", | |
publicPath: "assets/js" | |
}, | |
devtool: "source-map", | |
devServer:{ | |
historyApiFallback: true, | |
inline: true, | |
contentBase: './dist', | |
port: 3000 | |
}, | |
module:{ | |
loaders: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader' | |
}, | |
{ | |
test: /\.json$/, | |
exclude: /node_modules/, | |
loader: 'json-loader' | |
}, | |
{ | |
test: /\.css$/, | |
loaders: [ 'style-loader', 'css-loader?sourceMap', 'autoprefixer-loader' ] | |
}, | |
{ | |
test: /\.scss$/, | |
use: [{ | |
loader: "style-loader" | |
}, { | |
loader: "css-loader", options: { | |
sourceMap: true | |
} | |
}, { | |
loader: "autoprefixer-loader" | |
},{ | |
loader: "sass-loader", options: { | |
sourceMap: true, | |
data: '@import "./src/css/global.scss";', | |
includePaths: [ | |
path.join(__dirname, 'src'), | |
] | |
} | |
}], | |
include: path.join(__dirname, 'src') | |
}, | |
{ | |
test: /.*\.(gif|png|jpe?g|svg)$/i, | |
loader: 'url-loader?limit=100000' | |
}, | |
] | |
}, | |
}; |
This file contains 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 webpack = require('webpack'); | |
const path = require('path'); | |
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | |
module.exports ={ | |
entry: './src/client.js', | |
output:{ | |
path: path.resolve(__dirname, 'dist/assets/js'), | |
filename: 'bundle.js', | |
publicPath: 'assets/js' | |
}, | |
module:{ | |
loaders:[ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader' | |
}, | |
{ | |
test: /\.json$/, | |
exclude: /node_modules/, | |
loader: 'json-loader' | |
}, | |
{ | |
test: /\.css$/, | |
loader: [ 'style-loader', 'css-loader', 'autoprefixer-loader' ] | |
}, | |
{ | |
test: /\.scss$/, | |
use: [{ | |
loader: "style-loader" | |
}, { | |
loader: "css-loader", options: { | |
sourceMap: true | |
} | |
}, { | |
loader: "autoprefixer-loader" | |
},{ | |
loader: "sass-loader", options: { | |
sourceMap: true, | |
data: '@import "./src/css/global.scss";', | |
includePaths: [ | |
path.join(__dirname, 'src'), | |
] | |
} | |
}], | |
include: path.join(__dirname, 'src') | |
}, | |
{ | |
test: /.*\.(gif|png|jpe?g|svg)$/i, | |
loader: 'url-loader?limit=100000' | |
} | |
] | |
}, | |
plugins:[ | |
new UglifyJSPlugin({ sourcemap: false }), | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify('production') | |
} | |
}) | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment