// в вашем './src/app.js'
import './styles/main.sass';
// в конфиге вебпака все надо упростить
// entry
{
app: './src/app.js',
}
// module.rules
{
test: /\.sass$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
'sass-loader'
]
})
}
// plugins
new ExtractTextPlugin('styles/[name].css')
const API = process.env.api;
module.exports = {
...,
plugins: [
...,
new webpack.DefinePlugin({
API_URL: JSON.stringify(API)
})
]
}
{
"scripts": {
"build": "webpack --env.api=https://api.url/v1"
}
}
npm run build -- --env.api=https://api.url/v2
output.publicPath: '/bundles/'
output.filename: './dist/main.js'
на:output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
}
publicPath: '/dist/'
на:contentBase: path.resolve(__dirname, 'dist')
new ExtractTextPlugin('[name].css')
, output.path уже указывает, что надо выгружать все в dist {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel',
query: {
cacheDirectory: true,
plugins: ['transform-runtime', 'transform-decorators-legacy'],
presets: ['es2015', 'react', 'stage-0']
}
}
By default every local <img src="image.png">
is required (require('./image.png')). You may need to specify loaders for images in your configuration (recommended file-loader or url-loader).
resolve: {
root: path.resolve(__dirname, 'source')
}
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
loader:'file',
query: {
name: 'img/[name].[ext]'
}
}