webpack.config.js
const path = require("path");
const babiliPlugin = require("babili-webpack-plugin");
const extractTextPlugin = require("extract-text-webpack-plugin");
let plugins = [];
plugins.push(new extractTextPlugin('styles.css'));
// babiliPlugin = plugin para minificação de arquivo css | js
if (process.env.NODE_ENV == 'production') {
plugins.push(new babiliPlugin());
}
module.exports = {
entry: './app-src/app.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: 'dist'
},
module: {
rules: [
{
test: /\.js$/,
exclude: '/node_modules/',
use: {
loader: 'babel-loader'
}
},
{ test: /\.css$/, loader: 'style-loader!css-loader' },
// {
// test: /\.css$/,
// use: extractTextPlugin.extract({
// fallback: 'style-loader',
// use: 'css-loader'
// })
// },
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
}
]
},
plugins
}
package.json
{
"name": "client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-dev": "webpack --config webpack.config.js",
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.config.js",
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"bootstrap": "^3.3.7",
"reflect-metadata": "^0.1.10"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-systemjs": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babili-webpack-plugin": "^0.1.1",
"cross-env": "^5.0.1",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.11.2",
"style-loader": "^0.18.2",
"url-loader": "^0.5.9",
"webpack": "^3.1.0",
"webpack-dev-server": "^2.5.1"
}
}