Answer the question
In order to leave comments, you need to log in
How to set up output.publicPath?
Good afternoon, I ask you not to strongly pinnat webpack assemblies, I just study). In general, there is such a config
let path = require('path');
let webpack = require('webpack');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
let globImporter = require('node-sass-glob-importer');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let autoprefixer = require('autoprefixer');
let conf = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, './assets'),
filename: 'main.js'
},
devServer: {
overlay: true,
port: 3010
},
module: {
rules: [
{
test:/\.(js|jsx)$/,
loader: "babel-loader",
exclude:"/node_modules/"
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract([
{
loader: 'css-loader'
},
{
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
browsers:['ie >= 8', 'last 4 version']
})
],
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
importer: globImporter()
}
}
])
},
{
test: /\.(pug|jade)$/,
loader: 'pug-loader',
options: {
pretty: true
}
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
},
},
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 70
}
}
},
{
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: [{
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
}]
}
]
},
plugins: [
new ExtractTextPlugin({
filename: 'style.css'
}),
new HtmlWebpackPlugin({
template: './src/index.pug'
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
})
]
};
module.exports = conf;
publicPath: '/assets/'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question