webpack.config.js
//webpack.config.js
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = function(env) {
return {
entry: "./js/app.js",
output: {
path: __dirname + "/dist",
filename: "main.js"
},
module: {
rules: [{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//use: ['css-loader', 'postcss-loader', 'sass-loader']
use: [
{
loader: "css-loader",
options: {
url: false,
minimize: true,
}
},
{
loader: "postcss-loader",
},
{
loader: "sass-loader",
}
]
})
}]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
files: ['./*.html','./css/*.scss'],
proxy: 'local.webpack',
}),
new ExtractTextPlugin('style.css'),
new UglifyJsPlugin(),
]
}
}
package.json
{
"name": "archicenter",
"version": "1.0.0",
"description": "[](https://travis-ci.org/Automattic/_s)",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"browser-sync": "^2.23.2",
"jquery": "^3.2.1",
"jquery-colorbox": "^1.6.4",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"browser-sync-webpack-plugin": "^1.2.0",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.2",
"node-sass": "^4.7.2",
"postcss-loader": "^2.0.9",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.1",
"uglifyjs-webpack-plugin": "^1.1.6",
"webpack": "^3.10.0"
}
}
postcss.config.js (w tym samym katalogu, co webpack.config.js
module.exports = {
plugins: [
require('autoprefixer')
]
}
Do tego proponuję jeszcze ukryć komunikaty przy odświeżaniu
browserSync.init({
`notify: false`
});